-
Notifications
You must be signed in to change notification settings - Fork 52
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
Request added to response and response error #36
Request added to response and response error #36
Conversation
// Register fetch call | ||
promise = promise.then(args => fetch(...args)); | ||
promise = promise.then(args => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe in race conditions? i.e. what happens if a second fetch
is started before the first one returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats correct we need to nest the a second promise that extends the response
object. Then you can use const request
instead of let
which gives additional safety in this regard.
Can this be accepted ? I need this on my project 👍 |
I can't. The current implementation is not save for concurrent requests. |
I've made the modification, hope that is the expected one |
3e93dfb
to
d3f546f
Compare
d3f546f
to
6a069f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good. Could you also extend the type definitions in src/index.d.ts
?
Is that the right way, I don't usually use typescript. |
Released in 2.4.0 |
Add the request in the response.
It help when you intercept an error and want to resend the request.
(I used to work like this with axios, and this feature is missing with fetch)
PS: Hope the commit history is now clean enough ;)