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