Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
Update aniAdvanceSearch.js
Browse files Browse the repository at this point in the history
  • Loading branch information
DevanAbinaya committed Nov 17, 2023
1 parent 7870a54 commit e7b21be
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/anilist/aniAdvanceSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down

0 comments on commit e7b21be

Please sign in to comment.