fetch-intercept icon indicating copy to clipboard operation
fetch-intercept copied to clipboard

Include fetch request inside Response and ResponseError

Open lupes96 opened this issue 4 years ago • 4 comments

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?

lupes96 avatar Jul 07 '20 01:07 lupes96

Can delete this issue, created my own solution

lupes96 avatar Jul 07 '20 02:07 lupes96

@lupes96 can you please share how you solved the problem? Will really appreciate that.

kautukkundan avatar Jul 18 '20 11:07 kautukkundan

Can delete this issue, created my own solution

Can you share your solution?

vitorcamachoo avatar May 31 '21 17:05 vitorcamachoo

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
        })
    }

joshhunt avatar Jan 30 '22 04:01 joshhunt