# fetch-22

> GET and POST JSON with less code and more convention.

Latest version **1.0.0** (published 2017-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install fetch-22
pnpm add fetch-22
yarn add fetch-22
bun add fetch-22
```

## 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-12-30 |
| First published | 2017-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aslakhellesoy |

## Links

- npm: https://www.npmjs.com/package/fetch-22
- npm.io page: https://npm.io/package/fetch-22

## Recent versions

- 1.0.0 (latest) — 2017-12-30

## README

# Fetch-22

GET and POST JSON with less code and more convention.

First, instantiate it:

```javascript
const fetch = window.fetch.bind(window) // require('node-fetch')
const baseUrl = 'http://localhost:9988'
const fetch22 = new Fetch22({ baseUrl, fetch })
```

Second, use it:

```javascript
// GET
const obj = await fetch22.get('/foo')

// POST
await fetch22.post('/foo', { bar: 'zap' })
```

`get` throws an error when the response isn't 200. `post` throws an error when the response isn't 201.
The error contains the response body as text as well as the actual status code.

That's what we need 22% of the time. For the remaining 78% of cases, don't use Fetch-22.

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