From e57638e87c5a70104b48f3e04de9e9a2201ed3dd Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 17 Dec 2021 23:40:47 -0500 Subject: [PATCH] fix: handle invalid json response --- functions/src/twitch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/twitch.ts b/functions/src/twitch.ts index 712acf65d..5108873b9 100644 --- a/functions/src/twitch.ts +++ b/functions/src/twitch.ts @@ -34,7 +34,7 @@ export async function getTwitchLogin(uid: string, id: string) { const json = await response.json(); - if (json["data"].length == 0) { + if (!json || !json["data"] || json["data"].length == 0) { return null; } return json["data"][0]["login"] as string;