From 8387ce2ad19068bf9c8299c193fdc0f5e933de6f Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 16 Jun 2021 22:03:23 -0500 Subject: why did it break --- src/mojang.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/mojang.ts') 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 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 -- cgit