Skip to content
Advertisement

How can I use Axios interceptors to add some headers to responses?

In my Reactjs app , I want to add an interceptor which can append some headers to some backend responses

So, I tried this :

JavaScript

And I suppose like that that my header would be append in every back-end response. But that doesn’t seem to work.

Suggestions ??

Advertisement

Answer

Add a request interceptor

JavaScript

Add a response interceptor

JavaScript

Click here to see the topic in detail.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement