# xhr-status

> Normalize XHR status code/text across various of environments

Latest version **1.0.1** (published 2018-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install xhr-status
pnpm add xhr-status
yarn add xhr-status
bun add xhr-status
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-01-15 |
| First published | 2015-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Arnout Kazemier |
| Maintainers | 3rdeden |
| Keywords | status, statuscode, text, code, statustext, xhr |

## Links

- npm: https://www.npmjs.com/package/xhr-status
- Repository: https://github.com/unshiftio/xhr-status
- Issues: https://github.com/unshiftio/xhr-status/issues
- npm.io page: https://npm.io/package/xhr-status

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-01-15
- 1.0.0 — 2015-04-10

## README

# xhr-status

[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/xhr-status)[![Build Status][build]](https://travis-ci.org/unshiftio/xhr-status)[![Dependencies][david]](https://david-dm.org/unshiftio/xhr-status)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/xhr-status?branch=master)[![IRC channel][irc]](http://webchat.freenode.net/?channels=unshift)

[made-by]: https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square
[version]: https://img.shields.io/npm/v/xhr-status.svg?style=flat-square
[build]: https://img.shields.io/travis/unshiftio/xhr-status/master.svg?style=flat-square
[david]: https://img.shields.io/david/unshiftio/xhr-status.svg?style=flat-square
[cover]: https://img.shields.io/coveralls/unshiftio/xhr-status/master.svg?style=flat-square
[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square

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:

- Captures thrown errors when accessing `statusText`
- Normalizes the `1233` status code in Internet Explorer for `204` content.
- Normalizes the `0` status code to `200` for `file://` requests.

## Installation

The module is released in the public npm registry and can be installed by
running:

```
npm install --save xhr-status
```

## Usage

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:

- **code** The XHR status code.
- **text** The XHR status text.

See for an implementation example:

```js
'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();
```

## License

MIT

---
_Source: https://npm.io/package/xhr-status · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
