fix mojang-api JSON.pharse
This commit is contained in:
parent
4ead835c7b
commit
b74e20ec22
|
@ -12,7 +12,7 @@ class MojangAPI {
|
||||||
const request = await axios.get(
|
const request = await axios.get(
|
||||||
`https://api.mojang.com/user/profile/${minecraft_uuid}`
|
`https://api.mojang.com/user/profile/${minecraft_uuid}`
|
||||||
);
|
);
|
||||||
id = JSON.parse(request.data).name;
|
id = request.data.name;
|
||||||
|
|
||||||
if (!id) throw new Error("Failed to get minecraft id from api");
|
if (!id) throw new Error("Failed to get minecraft id from api");
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ class MojangAPI {
|
||||||
let uuid = this.cached.get_by_second(minecraft_id);
|
let uuid = this.cached.get_by_second(minecraft_id);
|
||||||
if (uuid) return uuid;
|
if (uuid) return uuid;
|
||||||
|
|
||||||
const request = await axios.get(
|
const response = await axios.get(
|
||||||
`https://api.mojang.com/users/profiles/minecraft/${minecraft_id}`
|
`https://api.mojang.com/users/profiles/minecraft/${minecraft_id}`
|
||||||
);
|
);
|
||||||
uuid = JSON.parse(request.data).id;
|
uuid = response.data.id;
|
||||||
if (!uuid) throw new Error("Failed to get minecraft id from api");
|
if (!uuid) throw new Error("Failed to get minecraft id from api");
|
||||||
|
|
||||||
this.cached.remove_by_first(uuid);
|
this.cached.remove_by_first(uuid);
|
||||||
|
|
Loading…
Reference in a new issue