3 ms·
For me the Fetch API is basically that: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
by untog 7y ago
For me the Fetch API is basically that:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
fetch("http://www.example.com").then(res => res.json()).then(json => {})
Only big downside is no IE11 support but thankfully I don't have to worry about that so much these days.
- leetrout 7y agoIt still doesn't go POST in a nice way like the jQuery API does BUT it is not worth bringing jQuery to the page just for making requests with slightly nicer syntax.
- untog 7y agoWhat’s not nice about POST? fetch(url, { method: “POST”, body: “a body” })
- tyingq 7y agoIt has some limitations as well around timeouts, cross site cookies, and progress tracking (uploads, for example).
- untog 7y agoSure, but those aren’t common uses for $.ajax. Fetch can get you 95% of the way there.