xhrhelpers
v0.0.6
Published
xhr testing helper
Downloads
62
Readme
xhrhelpers
xhrhelpers contains function to help interacting with XHR objects through promises.
Usage
- Use the XHR status
promisifiedXHR
.then(xhrHelpers.status)
.then(console.log); // Logs the status of the xhr
- Use the XHR response object
promisifiedXHR
.then(xhrHelpers.responseObject)
.then(console.log); // Logs the response object of the xhr
- Use the XHR response text
promisifiedXHR
.then(xhrHelpers.responseText)
.then(console.log); // Logs the response text of the xhr
- Check if the status code was successful (under 299)
promisifiedXHR
.then(xhrHelpers.twoHundredsOrThrow)
.then(console.log); // Throws an error if the status code was > 299
Install it
$ npm install xhrhelpers
Test it
$ npm test