3 ms·
You should look at `fetch` which is the new specification for a promise based XHR wrapper. Polyfill: https://github.com/github/fetch https://github.com/github/
by vjeux 12y ago
You should look at `fetch` which is the new specification for a promise based XHR wrapper.
Polyfill: https://github.com/github/fetch https://github.com/github/fetch
To use Fetch in Firefox (38), you'll currently need to enable it — go to about:config, set dom.fetch.enabled to true, and restart the browser.
To use Fetch in Chrome 41/Opera 28, you need to enable the "Experimental Web Platform Features" pref in chrome://flags.
- antihero 12y agoYep, had a play around with fetch but it didn't seem ready and acted kind of weird. Can't remember exactly what was wrong as it was a while ago. I imagine once fetch is decent, most libraries like this won't be hugely useful, but in the mean time, something like xr is a nice way to have a very tiny dependency that makes making AJAX requests just that little bit nicer.
- VeejayRampay 12y agoLooks awesome, though the name fetch does work better for GET requests than for POST/PUT/PATCH/DELETE.
- Touche 12y agoReally sad they choose "giant options object" for the api. Makes it pretty difficult to compose.
- frio 12y agoWhile I was a little sad about the API too, what would you propose that's better? Connection-less network IO seems like it'd very easily devolve to a "giant options object", and this lets you at least incrementally build that options object on the path from your code to this API.
- sonnyp 12y agoFetch doesn't support progress events nor reading headers before processing the body.