diff options
| author | Factiven <[email protected]> | 2023-07-16 22:35:39 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-07-16 22:35:39 +0700 |
| commit | 1eee181e219dfd993d396ac3169e7aad3dd285eb (patch) | |
| tree | 23fe54e9c3f8810f3ac9ab6b29070b4f0d4b9d20 /lib/anilist/AniList.js | |
| parent | removed console.log (diff) | |
| download | moopa-1eee181e219dfd993d396ac3169e7aad3dd285eb.tar.xz moopa-1eee181e219dfd993d396ac3169e7aad3dd285eb.zip | |
Update v3.6.4
- Added Manga page with a working tracker for AniList user
- Added schedule component to home page
- Added disqus comment section so you can fight on each other (not recommended)
- Added /id and /en route for english and indonesian subs (id route still work in progress)
Diffstat (limited to 'lib/anilist/AniList.js')
| -rw-r--r-- | lib/anilist/AniList.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/anilist/AniList.js b/lib/anilist/AniList.js new file mode 100644 index 0000000..f602dad --- /dev/null +++ b/lib/anilist/AniList.js @@ -0,0 +1,54 @@ +export async function aniListData({ sort, page = 1 }) { + const resAnilist = await fetch(`https://graphql.anilist.co`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + query: ` + query ( + $id: Int + $page: Int + $perPage: Int + $search: String + $sort: [MediaSort] + ) { + Page(page: $page, perPage: $perPage) { + pageInfo { + total + currentPage + lastPage + hasNextPage + perPage + } + media(id: $id, search: $search, sort: $sort type: ANIME) { + id + idMal + title { + romaji + english + } + coverImage { + extraLarge + } + description + } + } + } + `, + variables: { + page: page, + perPage: 15, + sort, + }, + }), + }); + const anilistData = await resAnilist.json(); + const data = anilistData.data.Page.media; + // console.log(resAnilist); + return { + props: { + data, + }, + }; +} |