Conversation
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
|
Tests are needed to demonstrate why this feature is needed. I need to know the use case for this to be honest. |
@bitinn There's a use case explained here: #668 (comment) |
bitinn
left a comment
There was a problem hiding this comment.
I do not believe we have reached a consensus on middleware design, so putting this on hold
|
Before doing something like this i would want to start on crating a constructor to get a new fetch instance that don't conflict with others middleware hooks
|
|
Also useful for using automatic follow redirect but in the end get all the redirect that there were in the middle. |
|
This is more of |
|
I agree with @JefferyHus, and would like to add that I think that global hooks like this are quite messy. If someone uses this to e.g. parse errors returned from an api, it can easy interfere with any other responses being returned from other parts of the code... Also, should we really add features that aren't present in the official |
@LinusU The main reason why we want to introduce a middleware functionality/hooks is to allow users to set up things like caching/cookies, which are in the spec, but can't be added to node-fetch in an unopinionated way. |
|
We can allow the consumer to specify separate hooks as an option like from got. |
|
@xxczaki thanks for the clarification, I still think that it shouldn't be global though. I think that |
|
@LinusU Yeah, I also really like |
|
This PR have been idle for to long (created 2019) and never merged and perhaps outdated as well?. with some consideration i think FetchEvent #370 is better suited - so closing this... |
This PR adds basic middleware functionality. I'm not sure how to test this.