Replace axios with a simple custom fetch wrapper(kentcdodds.com)
kentcdodds.com
Replace axios with a simple custom fetch wrapper
https://kentcdodds.com/blog/replace-axios-with-a-simple-custom-fetch-wrapper
4 comments
In the case of authentication redirect, any inflight request is going to fail and you're about to navigate in a few milliseconds, so I don't resolve those promises. Return new Promise(() => {}).
I’m all for replacing as much 3rd party libs with stdlib but it’s hard to look past the storing of the jwt in localStorage. Please don’t do that people. It’s very easily extracted through xss attacks.
A cookie is susceptible to both xss and CSRF. You ought to be protecting against xss anyway.