| ▲ | kamranjon 3 hours ago | |||||||||||||||||||||||||||||||
In what ways has fetch never caught up to axios? I have not encountered a situation where I could not use fetch in the last 5 years so I'm just curious what killer features axios has that are still missing in fetch (I certainly remember using axios many moons ago). | ||||||||||||||||||||||||||||||||
| ▲ | junon 2 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||
Missing a lot of event hooks that axios/ky give you. | ||||||||||||||||||||||||||||||||
| ▲ | mattmanser 2 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Simple examples are interceptors and error handling. Fetch is one of those things I keep trying to use, but then sorely regret doing so because it's a bit rubbish. You're probably reinventing axios functionality, badly, in your code. It's especially useful when you want consistent behaviour across a large codebase, say you want to detect 401s from your API and redirect to a login page. But you don't want to write that on every page. Now you can do monkey patching shenanigans, or make your own version of fetch like myCompanyFetch and enforce everyone uses it in your linter, or some other rubbish solution. Or you can just use axios and an interceptor. Clean, elegant. And every project gets to a size where you need that functionality, or it was a toy and who cares what you use. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||