Open
Description
Description
I want to create an Authentication interceptor that whenever the JWT token is expired aborts the requests since there is no need to to keep them alive if they're going to return 401 anyway. In order to do so I need a way to access either the AbortController
or the abort()
function in the MiddlewareOnRequest
onRequest
callback.
Proposal
Instantiate a new AbortController()
and expose either the controller itself or its abort()
function in the MiddlewareOnRequest
onRequest
callback.
const authInterceptor: Middleware = {
async onRequest({ request, controller, abort }) {
// Use either abort() or controller.abort()
}
}
Example of AbortController
usage:
const controller = new AbortController()
const signal = controller.signal
fetch(urlToFetch, {
method: 'get',
signal: signal,
})
controller.abort()
Checklist
- I’m willing to open a PR for this (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Accepted