Throw json data properly

This commit is contained in:
Tarrgon
2026-01-09 20:40:03 -05:00
parent a48c4f9bea
commit f79cdad3ee
+9 -2
View File
@@ -105,8 +105,15 @@ export class DiscordOAuth2 {
if (res.status < 200 || res.status >= 300) { if (res.status < 200 || res.status >= 300) {
console.error(`Non 200 code while joining user: ${options.userId} to discord:`); console.error(`Non 200 code while joining user: ${options.userId} to discord:`);
console.log(await res.text()); const text = await res.text();
return null; console.error(text);
let data = null;
try {
data = JSON.parse(text);
} catch { }
throw data;
} }
return await res.json(); return await res.json();