From b68a711c131d29a396440f2f76963ec5593aa3e7 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 17 Jun 2022 14:02:20 -0500 Subject: Show entire JSON if failed to parse --- src/routes/player/[player]/[profile].svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/routes/player/[player]/[profile].svelte b/src/routes/player/[player]/[profile].svelte index caf348b..bc6c18d 100644 --- a/src/routes/player/[player]/[profile].svelte +++ b/src/routes/player/[player]/[profile].svelte @@ -8,7 +8,14 @@ const profile: string = params.profile const data: CleanMemberProfile = await fetch( `${API_URL}player/${player}/${profile}?customization=true` - ).then(r => r.json()) + ).then(async r => { + const text = await r.text() + try { + return JSON.parse(text) + } catch (e) { + throw new Error(`Invalid JSON: ${text}`) + } + }) if (!data.member) { return { -- cgit