Handle invalid tokens

This commit is contained in:
2023-06-13 15:29:15 +02:00
parent c979e77c54
commit b3e1a4544c
2 changed files with 19 additions and 5 deletions

View File

@ -44,6 +44,13 @@ export class APIClient {
data = await res.json();
else data = await res.blob();
// Handle expired tokens
if (res.status === 412) {
AuthApi.RemoveAuthToken();
// eslint-disable-next-line no-self-assign
window.location.href = window.location.href;
}
if (!args.allowFail && !res.ok)
throw new ApiError("Request failed!", res.status, data);