fix(dashboard): show error message returned by api in discord login page

This commit is contained in:
spiral 2022-06-21 22:23:25 -04:00
parent b04b6e38d2
commit 6c4bd2cc26
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -12,7 +12,12 @@
const paramkeys = [...params.keys()]; const paramkeys = [...params.keys()];
if (paramkeys.includes("code")) if (paramkeys.includes("code"))
{ {
const res = await api().private.discord.callback.post({ data: { code: params.get("code"), redirect_domain: window.location.origin } }); let res: any;
try {
res = await api().private.discord.callback.post({ data: { code: params.get("code"), redirect_domain: window.location.origin } });
} catch(e) {
text = "Error: " + e.data.error;
}
localStorage.setItem("pk-token", res.token); localStorage.setItem("pk-token", res.token);
localStorage.setItem("pk-user", JSON.stringify(res.system)); localStorage.setItem("pk-user", JSON.stringify(res.system));
localStorage.setItem("pk-config", JSON.stringify(res.config)); localStorage.setItem("pk-config", JSON.stringify(res.config));