fetch-intercept
fetch-intercept copied to clipboard
Include fetch request inside Response and ResponseError
Similar logic to how the axios interceptor works. So for any 400 errors, we can refresh the token and send back the original request.
But without access to the original request and request body, this isn't possible.
There seems to be PR #36 open which addresses this, but it hasn't been merged.
Any update if / when this might get done?
Can delete this issue, created my own solution
@lupes96 can you please share how you solved the problem? Will really appreciate that.
Can delete this issue, created my own solution
Can you share your solution?
interceptor.response
itself can return a Promise of a Response.
response: (response) => {
return fetch("https://my.api/request")
.then(apiResp => apiResp.json())
.then((apiData) => {
const modifiedResponse = new Response(JSON.stringify(apiData), response);
return modifiedResponse
})
}