diff --git a/lib/anilist/aniAdvanceSearch.js b/lib/anilist/aniAdvanceSearch.js index 7e684afe..ccfbd274 100644 --- a/lib/anilist/aniAdvanceSearch.js +++ b/lib/anilist/aniAdvanceSearch.js @@ -24,8 +24,12 @@ export async function aniAdvanceSearch({ }, {}); if (type === "MANGA") { + const controller = new AbortController(); + const signal = controller.signal; + const response = await fetch("https://api.anify.tv/search-advanced", { method: "POST", + signal: signal, body: JSON.stringify({ sort: "averageRating", sortDirection: "DESC", @@ -42,13 +46,13 @@ export async function aniAdvanceSearch({ const data = await response.json(); return { pageInfo: { - hasNextPage: data.length >= (perPage ?? 20), + hasNextPage: page < data.total, currentPage: page, - lastPage: Math.ceil(data.length / (perPage ?? 20)), + lastPage: Math.ceil(data.lastPage), perPage: perPage ?? 20, - total: data.length, + total: data.total, }, - media: data.map((item) => ({ + media: data.results?.map((item) => ({ averageScore: item.averageRating, bannerImage: item.bannerImage, chapters: item.totalChapters,