Hello community! I come with what I consider an interesting question because I continue to see the Axios library referred a lot everywhere, even i...
For further actions, you may consider blocking this person and/or reporting abuse
If your app is a single page app and heavily interacts with backend through APIs you may notice that most of the methods require common user data to pass to backend. For example a token header or custom cookies etc. If you use fetch then for every possible endpoint you've to write all those things for each fetch request. However, in axios you can create a session with commonly required data that needs to be sent, and in your actual call to endpoint you only add additional information that is required.
I've not used axios more than this, so I would also like to know more points from others.
Awesome. Thanks for sharing. Indeed, my team is using
fetch()
but we do have the requirement you say. Makes me wonder how they did it withfetch()
. Maybe I should check their code. I fear I'll find a mess! Hehe.So this sounds like a solid point in favor of Axios.
FYI, there are apiClient out there uses fetch, I personally use Wretch daily
dev.to/marklai1998/why-im-ditching...
res.json()
everywhereIn my opinion
fetch
has gotten really good over the years and there's no real use case for axios. I think people just use it because they are used to it.Alright. Fair enough. Tabulated the reason. Many thanks!
I haven't used axios in 5+ years now. A small wrapper around fetch is all you really need.
FYI, there are apiClient out there uses fetch, I personally use Wretch daily
dev.to/marklai1998/why-im-ditching...
Also, check this geeksforgeeks link
Thanks for stopping by. some interesting points in that table, although one is clearly wrong, as
fetch()
can be cancelled through anAbortController
object. Also the first one in the table sounds suspicious becausefetch()
's Request object does have the url property.In any case, I'll tabulate some more. Cheers!
Didn't know, thanks for sharing!
Mainly about master configuration. It's all about the DRY principle all over again.