aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-04-17 15:17:49 +0700
committerFactiven <[email protected]>2023-04-17 15:17:49 +0700
commit3c47208eb3980b9e155f49eee1a142e7cf96f101 (patch)
tree3418e5ae175443cca3ca3ddd7e5b04e11e146ab4
parentUpdate get-user.js (diff)
downloadmoopa-3c47208eb3980b9e155f49eee1a142e7cf96f101.tar.xz
moopa-3c47208eb3980b9e155f49eee1a142e7cf96f101.zip
Update [user].js
-rw-r--r--pages/profile/[user].js70
1 files changed, 66 insertions, 4 deletions
diff --git a/pages/profile/[user].js b/pages/profile/[user].js
index f3c6485..bd80a6c 100644
--- a/pages/profile/[user].js
+++ b/pages/profile/[user].js
@@ -299,11 +299,73 @@ export async function getServerSideProps(context) {
const session = await getServerSession(context.req, context.res, authOptions);
const query = context.query;
- const res = await fetch(
- `https://moopa-anilist.vercel.app/api/get-media?username=${query.user}`
- );
+ const response = await fetch("https://graphql.anilist.co/", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ query: `
+ query ($username: String, $status: MediaListStatus) {
+ MediaListCollection(userName: $username, type: ANIME, status: $status, sort: SCORE_DESC) {
+ user {
+ id
+ name
+ about (asHtml: true)
+ createdAt
+ avatar {
+ large
+ }
+ statistics {
+ anime {
+ count
+ episodesWatched
+ meanScore
+ minutesWatched
+ }
+ }
+ bannerImage
+ mediaListOptions {
+ animeList {
+ sectionOrder
+ }
+ }
+ }
+ lists {
+ status
+ name
+ entries {
+ id
+ mediaId
+ status
+ progress
+ score
+ media {
+ id
+ status
+ title {
+ english
+ romaji
+ }
+ episodes
+ coverImage {
+ large
+ }
+ }
+ }
+ }
+ }
+ }
+ `,
+ variables: {
+ username: query.user,
+ },
+ }),
+ });
+
+ const data = await response.json();
- const get = await res.json();
+ const get = data.data.MediaListCollection;
const sectionOrder = get?.user.mediaListOptions.animeList.sectionOrder;
if (!sectionOrder) {