Skip to content
Advertisement

Pass parameter/argument to axios interceptor

How do I send custom parameters to the axios interceptor? I am using an interceptor like this:

JavaScript

I also have a response interceptor that needs to receive the same parameter.

Advertisement

Answer

The method suggested by @Laurent will cause axios to wipe out all your other parameters and replace it with my_variable, which is may not exactly what you want.

The proper way of adding default parameters instead of replacing it is like this:

JavaScript

This works with axios 0.18.1. It does not work with axios 0.19 due to a regression bug…, I believe it will be fixed soon.

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