Add message for when unauthorised
This commit is contained in:
parent
fddf9cbbaf
commit
5a9e55c695
@ -34,8 +34,12 @@ export async function apiGet(path: string): Promise<any> {
|
|||||||
try {
|
try {
|
||||||
const res = await fetch(getUrlString() + path, options);
|
const res = await fetch(getUrlString() + path, options);
|
||||||
|
|
||||||
|
if (res.status === 401) {
|
||||||
|
throw new Error("Registration not accepted. Register at `Menu > Registration`");
|
||||||
|
}
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error("Network response not ok");
|
throw new Error(`Failed: ${res.status}: ${res.statusText}`);
|
||||||
}
|
}
|
||||||
const contentType = res.headers.get("content-type");
|
const contentType = res.headers.get("content-type");
|
||||||
if (!contentType || !contentType.includes("application/json")) {
|
if (!contentType || !contentType.includes("application/json")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user