redux-requests icon indicating copy to clipboard operation
redux-requests copied to clipboard

Non Agonisitc Interceptors

Open theigwe opened this issue 4 years ago • 1 comments

How can I handle interceptors globally, having different interceptor for each driver in a multiple driver setup without having to do that in reducers?

theigwe avatar Oct 15 '21 13:10 theigwe

I guess you mean interceptors in this context? https://redux-requests.klisiczynski.com/docs/tutorial/6-interceptors

Those interceptors are globally used, but you can use requestAction.meta.driver to have a different logic per driver.

Additionally, drivers are promised based (see how to write them - https://redux-requests.klisiczynski.com/docs/drivers/using-drivers#writing-your-own-driver), so you can just use then and catch to have some dedicated interceptors on a driver level.

If you go with driver approach, you don't need to write your own driver, you can wrap existing ones like axios driver to add your then and catch handlers

klis87 avatar Oct 15 '21 20:10 klis87