3 ms·
Isn't fetch widespread enough to use these days?
by petepete 9y ago
Isn't fetch widespread enough to use these days?
- sametmax 9y agoOnly if you want to ignore 12% market share or use a polyfill: https://caniuse.com/#search=fetch https://caniuse.com/#search=fetch https://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0 https://www.netmarketshare.com/browser-market-share.aspx?qpr... Plus, although fetch is tremendously better than XMLHttpRequest, it still has quirks. It doesn't send cookies by default. The promise resolve on success on code 400 and 500. Headers are verbose. You have to encode and decode json manually. You have to force CORS for it to work. The end of this article show you the problem: https://medium.com/@shahata/why-i-wont-be-using-fetch-api-in-my-apps-6900e6c6fe78 https://medium.com/@shahata/why-i-wont-be-using-fetch-api-in... Eventually you end up writting code to wrap fetch. So why not just use jquery or axios ? It's already documented and tested.