Show HN: Xr – A modern ES6 Promise-based XMLHttpRequest wrapper
github.com
github.com
Polyfill: 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.
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.
The other handy feature is that it will use whichever Promise library that's available in the global namespace, so as long as that conforms to the spec, it will happily work with it.
Also, title should be lower case, as with most node modules.
There are other valid 20x return codes that indicate success, such as 202 Accepted and 204 No Content.
I guess a discussion would be a bunch of example situations and whether they needed to be treated specially.
I'll make if status >= 200 and < 300, we accept it in the next version.
EDIT: Apparently this was changed recently and was actually broken at time of posting.
Another nice side effect is that if you use 2-spaces then your promise .then lines up with the initial call...
xr.get()
.then(...)