3 ms·
Lots of us remember the days of XmlHTTPRequest. Fetch is downright modern in comparison. You should understand how your browser actually works and in this case,
by hajile 6y ago
Lots of us remember the days of XmlHTTPRequest. Fetch is downright modern in comparison. You should understand how your browser actually works and in this case, it's actually gotten a lot easier.
- nailer 6y agoI don't think you quite understood the point: XHR was not fetches predecessor, because few people were using XHR directly when fetch was being designed and released. superagent was released in 2011, axios was released in 2014 (jQuery also had an HTTP client that was nice but I don't know much about it). Both of these libraries were wildly popular and do more out of the box than fetch (which came later) does. Standards should pave cowpaths. Fetch was designed in a bubble.
- duxup 6y agoI think fetch provides plenty of value to most people. If someone wants axios, they can use it, but I find fetch plenty useful without having to use another library.
- nailer 6y agoDo you use JSON? Use HTTP headers? Encode query strings? Do post requests? All those things take less code in any popular HTTP client released before fetch.
- kingdomcome50 6y agoI use all of those things, and cannot fathom why someone would feel like they need to reach for something other than `fetch`. Is adding `{ method: “POST” }` or using `URLSearchParams` really that hard? I’ve never used axios, but I do see it often used in examples on the web, and every time I wonder why someone would feel like they need to save maybe 1-3 LoC at the expense of an example that doesn’t need a dependency (i.e. could be pasted into the console) Looking at the axios API now... it’s basically a passthru to `fetch` that defaults to JSON. It’s so thin! And at 346kB unpacked it’s almost twice the size of React... think about that for a second.
- nailer 6y agoTheyre not hard, they're unnecessary effort and bloat for every single request. You can write your own wrapper, or use someone else's. But DRY and avoid all the boilerplate on every request.
- kingdomcome50 6y ago> they're unnecessary effort and bloat for every single request Oh the irony!