# httperest

> fetch wrapper

Latest version **1.0.0** (published 2017-11-27) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2017-11-27 |
| First published | 2017-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mercoxit |
| Maintainers | mercoxit |
| Keywords | fetch, XMLHttpRequest, ajax |

## Links

- npm: https://www.npmjs.com/package/httperest
- Repository: https://github.com/mercoxit/httperest
- Homepage: https://github.com/mercoxit/httperest#readme
- Issues: https://github.com/mercoxit/httperest/issues
- npm.io page: https://npm.io/package/httperest

## Dependencies (2)

- [promise-polyfill](https://npm.io/package/promise-polyfill.md) ^6.1.0
- [react-native-fetch-polyfill](https://npm.io/package/react-native-fetch-polyfill.md) ^1.1.2

## 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

- 1.0.0 (latest) — 2017-11-27

## README

# httperest
fetch wrapper

### Installation
```bash
npm install --save httperest
```

### Usage
```javascript
import { request } from 'httperest'

request.get('http://example.com')
	.then(response => console.log(response)) // response as JSON
	.catch(error => console.log(error)) // error object { status, message }

```

or

```javascript
import Request from 'httperest'

const request = new Request(options)
request.get('http://example.com')
    .then(response => console.log(response)) // response as JSON
    .catch(error => console.log(error)) // error object { status, message }

```

### Methods
```javascript
request.get(url, options)
request.delete(url, options)
request.post(url, data, options)
request.put(url, data, options)
request.patch(url, data, options)
```

### Options
```javascript
const options = {
    cache: 'default', // default, no-store, reload, no-cache, force-cache, only-if-cached
    credentials: 'same-origin', // same-origin, omit, include
    timeout: 30000, // request timeout 30s by default
    headers: {
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/json'
    },
    mode: 'cors' // same-origin, no-cors, cors
}
```

### TODO
* Canceling request
* Tests coverage

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