aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mojang.ts11
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