From e54fefb0df5021ebf0e46b6bb07d45b90b14fd6c Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 10 Nov 2024 20:16:13 -0800 Subject: feat(user): add simple null check for remote user identity fetch --- src/lib/Data/AniList/user.ts | 11 +++++++---- 1 file 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 => - ( +export const user = async (username: string, id = false): Promise => { + const response = ( await ( await fetch('https://graphql.anilist.co', { method: 'POST', @@ -64,11 +64,14 @@ export const user = async (username: string, id = false): Promise => count meanScore chaptersRead volumesRead } } - } }` + } }` }) }) ).json() - )['data']['User']; + ) + + return response["data"]["User"] === null ? null : response["data"]["User"]; +} export const dumpUser = async (username: string): Promise => ( -- cgit v1.2.3