$ gnpm install xhr-status
Normalize the XHR status codes across various of environments. This eliminates all the odd browser bugs that you might run in to while working with XHR requests in browsers:
statusText
1233
status code in Internet Explorer for 204
content.0
status code to 200
for file://
requests.The module is released in the public npm registry and can be installed by running:
npm install --save xhr-status
This module exports a single function. The returned function accepts one single
argument which is a reference to the xhr
instance that you've created. It will
return an object with the following keys:
See for an implementation example:
'use strict';
var xhrstatus = require('xhr-status')
, xhr = new XMLHTTPRequest.
xhr.open('GET', 'http://google.com/gen_204', true);
xhr.onload = function () {
var status = xhrstatus(xhr);
console.log(status.code) // 204
console.log(status.text) // OK
};
xhr.send();
MIT
Copyright 2013 - present © cnpmjs.org | Home |