-
-
Notifications
You must be signed in to change notification settings - Fork 436
Closed
Description
Use-case: #776
Maybe we could make that simpler by allowing to force a retry?
I'm thinking returning a symbol, similar to how we have ky.stop:
const api = ky.extend({
hooks: {
afterResponse: [
async (request, options, response) => {
if (response.status === 200) {
const data = await response.clone().json();
if (data.error?.code === 'RATE_LIMIT') {
return ky.retry;
}
}
}
]
}
});This would skip retry.shouldRetry, but be observable in hooks.beforeRetry. It would be an internal error like KyForceRetry or something. ky.retry would only do something in afterResponse.
An alternative is to expose an error a user could throw in the afterResponse hook, but I kinda prefer returning rather than throwing for control flow.
Is this something worth solving? And any thoughts on the API?
Metadata
Metadata
Assignees
Labels
No labels