Adding unauthorized error handling in runMethod

This commit is contained in:
Vicg853
2022-01-10 20:41:25 -03:00
parent fccf169352
commit 2d7ad8d5b1
+6
View File
@@ -35,6 +35,12 @@ export async function runMethod<T = any>(
throw errorStack;
});
if (!result.ok) {
errorStack.message = result.statusText as Error['message'];
console.error(`Invalid authorization key.`);
throw errorStack;
}
return result.status !== 204 ? await result.json() : undefined;
}