Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include fetch request inside Response and ResponseError #48

Open
lupes96 opened this issue Jul 7, 2020 · 4 comments
Open

Include fetch request inside Response and ResponseError #48

lupes96 opened this issue Jul 7, 2020 · 4 comments

Comments

@lupes96
Copy link

lupes96 commented Jul 7, 2020

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 lupes96 closed this as completed Jul 7, 2020
@lupes96 lupes96 reopened this Jul 7, 2020
@lupes96
Copy link
Author

lupes96 commented Jul 7, 2020

Can delete this issue, created my own solution

@kautukkundan
Copy link

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

@vitorcamachoo
Copy link

Can delete this issue, created my own solution

Can you share your solution?

@joshhunt
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants