6 ms·
I still use on axios over fetch. Mainly because fetch doesn't have abort function. axios implements cancelable promise proposal that didn't go though TC39 Tho
by component 8y ago
I still use on axios over fetch. Mainly because fetch doesn't have abort function. axios implements cancelable promise proposal that didn't go though TC39
Tho it has been a while since I checked TC39 status on fetch
- mattwoodnyc 8y agoI also choose Axios over Fetch for now. I had the following post that made the case - https://medium.com/@thejasonfile/fetch-vs-axios-js-for-making-http-requests-2b261cdd3af5 https://medium.com/@thejasonfile/fetch-vs-axios-js-for-makin... Thoughts?
- mhagemeister 8y agoFetch requests do support cancelation for a while now through `AbortController`. See: https://developers.google.com/web/updates/2017/09/abortable-fetch https://developers.google.com/web/updates/2017/09/abortable-...
- igvadaimon 8y agoWhich doesn't work even in Chrome.
- suprfsat 8y ago> await (()=>{ controller=new AbortController; req=new Request('https://httpbin.org/delay/10',{signal:controller.signal}); f=fetch(req); controller.abort(); return f;})() Uncaught (in promise) DOMException: The user aborted a request. (index):1 Uncaught (in promise) DOMException: The user aborted a request. VM80:1 Fetch failed loading: GET "https://httpbin.org/delay/10". > navigator.userAgent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.45 Safari/537.36"
- thomasfoster96 8y agoFetch is a Web API, not an ECMAScript language feature, so TC39 doesn’t have much to do with it. They do do Promises though and Cancellation is a Stage 1 proposal [0], so it’s more than a year away from standardization at best. WHATWG handles Fetch and their spec[1] was updated seven days ago. [0] https://github.com/tc39/proposals/blob/master/README.md https://github.com/tc39/proposals/blob/master/README.md [1] https://fetch.spec.whatwg.org https://fetch.spec.whatwg.org