diff options
author | mat <github@matdoes.dev> | 2021-06-16 22:03:23 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-16 22:03:23 -0500 |
commit | 8387ce2ad19068bf9c8299c193fdc0f5e933de6f (patch) | |
tree | 0cfce97fb26678ca7465d110607fb7d0016f6ad8 /src/mojang.ts | |
parent | 134abd6cca8827ce7a7803a64f4d11a18000c038 (diff) | |
download | skyblock-api-8387ce2ad19068bf9c8299c193fdc0f5e933de6f.tar.gz skyblock-api-8387ce2ad19068bf9c8299c193fdc0f5e933de6f.tar.bz2 skyblock-api-8387ce2ad19068bf9c8299c193fdc0f5e933de6f.zip |
why did it break
Diffstat (limited to 'src/mojang.ts')
-rw-r--r-- | src/mojang.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mojang.ts b/src/mojang.ts index dd5c6bb..f73fe99 100644 --- a/src/mojang.ts +++ b/src/mojang.ts @@ -37,13 +37,22 @@ export async function profileFromUuid(uuid: string): Promise<MojangApiResponse> return await profileFromUuid(uuid) } + let dataString: string + try { + dataString = await fetchResponse.text() + } catch { + return { uuid: null, username: null } + } let data try { - data = await fetchResponse.json() + data = JSON.parse(dataString) } catch { + console.log('mojang response:', dataString) // if it errors, just return null return { uuid: null, username: null } } + if (!data.id) + console.log('mojang response:', data) return { uuid: data.id, username: data.name |