diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-24 22:18:41 -0500 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-24 22:18:41 -0500 |
commit | 1708632ee4746e116a21c546943381cce50ddc43 (patch) | |
tree | 9218a4a2ad58d313fdfadd853fa6c0047d89a51c /src | |
parent | f3834c6cdef26d15ee50df5859394f5446eb1928 (diff) | |
download | skyblock-api-1708632ee4746e116a21c546943381cce50ddc43.tar.gz skyblock-api-1708632ee4746e116a21c546943381cce50ddc43.tar.bz2 skyblock-api-1708632ee4746e116a21c546943381cce50ddc43.zip |
fix error on nonexistent users
Diffstat (limited to 'src')
-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 85c0185..61e5b55 100644 --- a/src/mojang.ts +++ b/src/mojang.ts @@ -27,7 +27,16 @@ export async function mojangDataFromUuid(uuid: string): Promise<MojangApiRespons `https://sessionserver.mojang.com/session/minecraft/profile/${undashUuid(uuid)}`, { agent: () => httpsAgent } ) - const data = await fetchResponse.json() + let data + try { + data = await fetchResponse.json() + } catch { + // if it errors, just return null + return { + uuid: null, + username: null + } + } return { uuid: data.id, username: data.name |