question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for axios interceptors?

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sebastiandedeynecommented, Apr 21, 2017

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 with npm list.

You’ve specified axios@^0.16, while this package requires axios@^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 via npm 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.

0reactions
sebastiandedeynecommented, Apr 26, 2017

As of v1.4.1, axios is a peer dependency, so you’ll need to install it in your application!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found