mlegenhausen / fetch-intercept

Interceptor library for the native fetch command inspired by angular http intercepts.
MIT License
406 stars 52 forks source link

Request Method as Async #25

Closed Harmonickey closed 6 years ago

Harmonickey commented 6 years ago

I have a requirement to get a JWT from a service using an async request, and I'll need that token to set as a header in the 'request' part of the fetch-intercept pipeline here. However, since request is sync, I cannot set the token correctly unless I wait for the token to come back before running any requests. I am already able to set the token as I'm describing using an HttpInterceptor in Angular since the intercept() method they implement has the option to be a Promise.

If you could do the same, just like you already have with requestFailure and the other methods, then that would make your library a magnitude more powerful.