fix: 401-401 retry on non-401, move login DOM bindings into page lifecycle, add abort support
This commit is contained in:
@@ -180,6 +180,13 @@ export async function apiFetch(url, options = {}) {
|
||||
if (retryRes.ok) {
|
||||
return { ok: json.ok, data: json.ok ? json.data : json, error: null, status: retryRes.status };
|
||||
}
|
||||
if (retryRes.status === 401) {
|
||||
redirectLogin();
|
||||
return { ok: false, data: null, error: 'Session expired', status: 401 };
|
||||
}
|
||||
if (!retryRes.ok) {
|
||||
return { ok: false, data: null, error: json.error || `HTTP ${retryRes.status}`, status: retryRes.status };
|
||||
}
|
||||
}
|
||||
redirectLogin();
|
||||
return { ok: false, data: null, error: 'Session expired', status: 401 };
|
||||
|
||||
Reference in New Issue
Block a user