web/api: remove deprecated statuses, update error type, time out request

also updated some error codes
This commit is contained in:
wukko
2024-08-06 20:50:20 +06:00
parent f96c1cd13b
commit ac6d68ec45
3 changed files with 24 additions and 9 deletions

View File

@@ -91,12 +91,22 @@ const request = async (url: string) => {
const response: Optional<CobaltAPIResponse> = await fetch(api, {
method: "POST",
redirect: "manual",
signal: AbortSignal.timeout(10000),
body: JSON.stringify(request),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(r => r.json()).catch(() => {});
}).then(r => r.json()).catch((e) => {
if (e?.message?.includes("timed out")) {
return {
status: "error",
error: {
code: "error.api.timed_out"
}
}
}
});
return response;
}