3 ms·
Kinda funny the author refuses to evaluate a five-year-old (?) standard (fetch), labeling it a trend/hype. And what are they holding onto? A third party library
by oefrha 6y ago
Kinda funny the author refuses to evaluate a five-year-old (?) standard (fetch), labeling it a trend/hype. And what are they holding onto? A third party library they “used before”; even cited the number of GitHub stars — i.e. aggregate trendiness — to justify the choice. Pretty sure at some point someone dismissed it as a trend and held onto their XHR, and they would have had a better point.
- nailer 6y ago> Kinda funny the author refuses to evaluate a five-year-old (?) standard (fetch), labeling it a trend/hype. And what are they holding onto? Fetch is a very poor standard if you compare it to high-level HTTP clients that have been around since 2010-ish. However it's author states that it wasn't intended as a general purpose HTTP library but rather a low level tool that-level tools can make use of. So yes: you probably don't want to use fetch directly, making Headers objects using obscure methods, manually encoding query strings, and telling your HTTP client that you'd like to treat application/json as JSON and decode it. Use a library.
- hajile 6y agoLots 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!