-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Hi,
The HTTP status code 401 indicates Unauthorized, as defined by the W3C specification or described on MDN. However, in the fetchClient.js file, the corresponding rejected promise returns a message labeled "Forbidden" (with a capital "F") instead. HTTP 403 status code (Forbidden) returns a rejection message using a lowercase "f".
const resp = await fetchRetry(fetch)(finalUrl, {
retries: 1,
retryDelay: function (attempt, error, response) {
return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
},
retryOn: [503, 502, 504, 500],
headers,
method,
body: init.body ? init.body : undefined,
signal: AbortSignal.timeout(timeout),
cache: 'no-store',
});
if (resp.status === 204) {
return resp;
}
else if (resp.status == 429) {
const limit = parseLimitFromResponse(resp);
return Promise.reject(new AxiomTooManyRequestsError(limit));
}
// error: Forbidden
else if (resp.status === 401) {
return Promise.reject(new Error('Forbidden'));
}
// error: forbidden
else if (resp.status >= 400) {
const payload = (await resp.json());
return Promise.reject(new Error(payload.message));
}
return (await resp.json());
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels