Refactored for GET request success/failure

pull/73/head
MillenniumEarl 2021-03-02 19:06:27 +01:00
parent c6765dab09
commit b10002dcc7
1 changed files with 14 additions and 12 deletions

View File

@ -30,20 +30,22 @@ export default async function fetchLatestHandiworkURLs(query: LatestSearchQuery,
const response = await fetchGETResponse(url); const response = await fetchGETResponse(url);
// Save the URLs // Save the URLs
//@ts-ignore if (response.isSuccess()) {
for(const result of response.data.msg.data) { //@ts-ignore
if(fetchedResults < limit) { for (const result of response.value.data.msg.data) {
const gameURL = new URL(result.thread_id, threadURL).href; if (fetchedResults < limit) {
resultURLs.push(gameURL); const gameURL = new URL(result.thread_id, threadURL).href;
fetchedResults += 1; resultURLs.push(gameURL);
fetchedResults += 1;
}
} }
}
// Increment page and check for it's existence
page += 1;
//@ts-ignore // Increment page and check for it's existence
if (page > response.data.msg.pagination.total) noMorePages = true; page += 1;
//@ts-ignore
if (page > response.value.data.msg.pagination.total) noMorePages = true;
} else throw response.value;
} }
while (fetchedResults < limit && !noMorePages); while (fetchedResults < limit && !noMorePages);