Support for axios interceptors?
See original GitHub issueI am using this package along with tymon/jwt-auth
in the backend. I was able to implement axios interceptors to catch certain error responses from jwt-auth.
However, on requests where I use the Form class instead of plain axios, I am unable to intercept the error responses. How do I implement this?
Note: I am aware that when using this package, the data can be accessed through error.data
instead of error.response.data
so I am sure that I am not incorrectly accessing the data.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Setting up Axios Interceptors for all HTTP calls in an application
Interceptors are a feature that allows an application to intercept requests or responses before they are handled by the .then() or the .catch() ......
Read more >How can you use axios interceptors? - Stack Overflow
Some request interceptor use cases - Assume you need to attach a token to every request made, instead of duplicating the token addition...
Read more >Interceptors | Axios Docs
You can intercept requests or responses before they are handled by then or catch . // Add a request interceptor axios.interceptors.request.use( ...
Read more >Setting Up Axios Interceptors For HTTP Calls With Refresh ...
In this tutorial, I'll show how to use Axios interceptors to intercept HTTP requests and how to use Refresh Tokens with Axios.
Read more >How to use Axios interceptors, a step-by-step guide with ...
In this tutorial, learn how to use Axios interceptors step by step with an example to track response duration for each Axios request....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dependencies listed in your
package.json
aren’t the same as your installed dependencies, since your packages dependencies each have their own dependencies, which in turn have their own dependencies etc. This turns into a dependency tree which can be viewed withnpm list
.You’ve specified
axios@^0.16
, while this package requiresaxios@^0.15
. Since these aren’t compatible according to semver, your application most likely has axios bundled twice, and your interceptors only apply to the other version (as stated, issues like this can be debugged vianpm list
).Since
^0.16
is the higher version between the two, this one would be preferable. Axios is a widely used (singleton!) library, so it would make sense for this package to require it as a peer dependency instead. I’ll decide what to do with this next week. If you need this to be fixed sooner, downgrade your own axios version to^0.15
.As of v1.4.1, axios is a peer dependency, so you’ll need to install it in your application!