aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-11-10 20:16:13 -0800
committerFuwn <[email protected]>2024-11-10 20:16:13 -0800
commite54fefb0df5021ebf0e46b6bb07d45b90b14fd6c (patch)
treeec8adfc53e98b579d274134db048e11441b9737b /src/lib/Data
parentdeps: refresh bun lockfile (diff)
downloaddue.moe-e54fefb0df5021ebf0e46b6bb07d45b90b14fd6c.tar.xz
due.moe-e54fefb0df5021ebf0e46b6bb07d45b90b14fd6c.zip
feat(user): add simple null check for remote user identity fetch
Diffstat (limited to 'src/lib/Data')
-rw-r--r--src/lib/Data/AniList/user.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/Data/AniList/user.ts b/src/lib/Data/AniList/user.ts
index 5b9390db..aaab6e0b 100644
--- a/src/lib/Data/AniList/user.ts
+++ b/src/lib/Data/AniList/user.ts
@@ -45,8 +45,8 @@ export interface FullUser {
about: string;
}
-export const user = async (username: string, id = false): Promise<User> =>
- (
+export const user = async (username: string, id = false): Promise<User | null> => {
+ const response = (
await (
await fetch('https://graphql.anilist.co', {
method: 'POST',
@@ -64,11 +64,14 @@ export const user = async (username: string, id = false): Promise<User> =>
count meanScore chaptersRead volumesRead
}
}
- } }`
+ } }`
})
})
).json()
- )['data']['User'];
+ )
+
+ return response["data"]["User"] === null ? null : response["data"]["User"];
+}
export const dumpUser = async (username: string): Promise<FullUser> =>
(