Skip to content

Commit

Permalink
Improve CC7 Changes error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
udjeni committed Nov 27, 2024
1 parent 16be745 commit ef3185b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/features/cc7_changes/cc7_changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,16 @@ async function fetchCC7FromAPI() {
limit: limit,
});
if (apiResult == null) return null;
const rspStatus = apiResult[0].status || "";
// Check if we're done
getMore = rspStatus.startsWith("Maximum number of profiles");
if (!getMore && rspStatus !== "") {
console.error("CC7 fetch aborted after API returned status: ", rspStatus);
showError(
`We received an unexpected response when retrieving your CC7: ${rspStatus}<br>It might help to try again later.`
);
return null;
}
const people = apiResult[0]?.people;
let restructuredResult;
if (people) {
Expand Down Expand Up @@ -637,8 +647,6 @@ async function fetchCC7FromAPI() {
peopleObjectArray = peopleObjectArray.concat(arrayOfObjects);

start += limit;
// Check if we're done
getMore = apiResult[0].status?.startsWith("Maximum number of profiles");
} else {
getMore = false;
}
Expand Down

0 comments on commit ef3185b

Please sign in to comment.