xhrhelpers

0.0.6 • Public • Published

xhrhelpers

Build Status

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

Readme

Keywords

none

Package Sidebar

Install

npm i xhrhelpers

Weekly Downloads

13

Version

0.0.6

License

MIT

Last publish

Collaborators

  • yola-readonly
  • yola-engineers