Are we still recommending to use axios? I know axios is excellent package but.. axios alova.js.org/ redaxios www.npmjs.com/... alova alova.js.org/ #nextjs14 #axios #http #react
fetch is cached here because I'm assuming you are using Next.js. This is not standard fetch behavior and is apparently something that Next.js team will potentially change because patching global fetch function isn't a good approach. Also, one example where axios is better is if you need to display file upload percentage. fetch API cannot at the moment track the progress of a file upload.
Response.ok checks whether the status is in the range 200-299 rather than just comparing it to 200. Axios defaults to rejecting its promise for statuses outside of that range, so this block is redundant.
Axios automatically parses json, and its interceptor interface is nice to use. Plus being able to configure an axios instance or set properties on axios global is nice compared to just wrapping fetch. Either tool works just fine.
I suppose thats because axios implements XMLHttpRequests under the hood? Fetch does not do that. (thats why only axios is able to keep track of upload progress for example)