# minixhr

> super simpel and small cross-browser xhr

Latest version **4.0.0** (published 2018-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install minixhr
pnpm add minixhr
yarn add minixhr
bun add minixhr
```

## 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 | 4.0.0 |
| Published | 2018-06-12 |
| First published | 2015-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | serapath |
| Maintainers | serapath |
| Keywords | xhr, mini, cors, http, request, browser, cross-browser, ajax |

## Links

- npm: https://www.npmjs.com/package/minixhr
- Repository: https://github.com/serapath/minixhr
- Issues: https://github.com/serapath/minixhr/issues
- npm.io page: https://npm.io/package/minixhr

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2018-06-12
- 3.2.2 — 2017-06-17
- 3.2.1 — 2017-03-25
- 3.2.0 — 2017-03-25
- 3.1.0 — 2016-07-10
- 3.0.4 — 2016-05-25
- 3.0.3 — 2016-02-19
- 3.0.2 — 2016-02-15
- 3.0.1 — 2016-02-15
- 3.0.0 — 2016-02-15
- 2.0.3 — 2016-02-15
- 2.0.2 — 2016-02-14
- 2.0.1 — 2016-02-14
- 2.0.0 — 2016-02-14
- 1.3.7 — 2015-12-27
- … 9 more at https://npm.io/package/minixhr/versions

## README

# minixhr
super simple and small cross-browser XMLHttpRequest (XHR)

# USAGE
```js
var minixhr = require('minixhr')

function response (error, data, header) {
  if (error) return console.error(error)
  console.log(data)
  console.log(header)
}

const string = JSON.stringify({ foo: 123, bar: "abc" }) // payload
const URL1 = 'https://jsonplaceholder.typicode.com/posts/1'
// @NOTE check http://requestb.in/18b4srl1?inspect after a request to inspect server
const URL2 = 'http://requestb.in/18b4srl1' // make a `http://requestb.in` to get your own

var request1 = URL1
var request2 = { // can be 'url string' or object:
  /*required*/url     : URL2,
  /*optional*/method  : 'POST',  // (defaults to `GET`)
    // can be any http method like `['GET', 'POST', 'HEAD', 'PUT', ...]` or `'JSONP'`
  /*optional*/data    : string,  // (defaults to: `undefined`)
    // can be any string, maybe formatted as e.g. <FORMDATA> or JSON e.g. '{"key":"val"}'
    // if set and no method provided, method will be set to 'POST'
  /*optional*/headers : {},      // (defaults to `{}`)
    // in case of `method === 'POST'` it defaults to:
    // {'X-Requested-With':'XMLHttpRequest','Content-Type':'application/x-www-form-urlencoded' }
  /*optional*/timeout : 1000,  // (defaults to `0`, wich means NO timeout)
    // can be any number of miliseconds, or "sync" (to make a synchronous request)
}

// EXAMPLE 1
minixhr(/*required*/request1, /*optional*/response)

// EXAMPLE 2
minixhr(/*required*/request2)
```

if you need to support old browsers, use version `3.1.0` or below.  
Those versions still include the [xhr polyfill](https://www.npmjs.com/package/xhrpolyfill)

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