contiamo / restful-react

A consistent, declarative way of interacting with RESTful backends, featuring code-generation from Swagger and OpenAPI specs 🔥
MIT License
1.87k stars 109 forks source link

Asynchronous onRequest/onResponse hooks #369

Closed benesch closed 3 years ago

benesch commented 3 years ago

Before making any request, the authentication library I use checks whether its current access token is valid and, if it is not, makes an API call to refresh the access token. Naturally this is an asynchronous process.

It'd be swell if onRequest (and onResponse too, I suppose, for good measure) supported async callbacks! That's the natural place to inject the authentication information, but since those functions are synchronous that doesn't work right now.

benesch commented 3 years ago

Oh, d'oh, requestOptions and onError already work like this and do exactly what I want. Sorry for the noise. Thanks for a great library!