aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-17 14:02:20 -0500
committermat <github@matdoes.dev>2022-06-17 14:02:20 -0500
commitb68a711c131d29a396440f2f76963ec5593aa3e7 (patch)
tree695febb6b81c4060c19497fac0905b768d65b5c7
parent573ffb17bdd6980532fff65987691f1d10b54189 (diff)
downloadskyblock-stats-b68a711c131d29a396440f2f76963ec5593aa3e7.tar.gz
skyblock-stats-b68a711c131d29a396440f2f76963ec5593aa3e7.tar.bz2
skyblock-stats-b68a711c131d29a396440f2f76963ec5593aa3e7.zip
Show entire JSON if failed to parse
-rw-r--r--src/routes/player/[player]/[profile].svelte9
1 files changed, 8 insertions, 1 deletions
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 {