# fetchres

> Some useful response handlers for using [Fetch](https://github.com/github/fetch) API in the real world.

Latest version **1.7.2** (published 2016-11-09) · 0 weekly downloads

## Install

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

## 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.7.2 |
| Published | 2016-11-09 |
| First published | 2015-01-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mattandrews, financial-times |

## Links

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

## Recent versions

- 1.7.2 (latest) — 2016-11-09
- 1.7.1 — 2016-11-09
- 1.7.0 — 2016-11-09
- 1.6.2 — 2016-11-09
- 1.6.1 — 2016-11-09
- 1.6.0 — 2016-10-18
- 1.5.1 — 2015-09-18
- 1.4.1 — 2015-08-12
- 1.4.0 — 2015-08-12
- 1.3.2 — 2015-08-12
- 1.3.1 — 2015-06-29
- 1.3.0 — 2015-06-24
- 1.2.0 — 2015-06-19
- 1.1.0 — 2015-03-19
- 1.0.5 — 2015-03-19
- … 13 more at https://npm.io/package/fetchres/versions

## README

# fetchres [![Build Status](https://travis-ci.org/matthew-andrews/fetchres.svg?branch=ynosubclass)](https://travis-ci.org/matthew-andrews/fetchres)

Some useful response handlers for using [Fetch](https://github.com/github/fetch) API in the real world.

Warning: doesn't come with Fetch or Promise, so you'll need to bring your own polyfill (unless you're using this module within Service Workers, where both `fetch` and `Promise` are already defined).

## Installation

```sh
npm install --save fetchres
```

Or

```sh
bower install --save fetchres
```

## Usage (node)

```js
var fetchres = require('fetchres');

fetch('https://mattandre.ws/my-json-endpoint')
	.then(fetchres.json)
	.then(function(data) {
		// `data` is an object containing the data
		// from the response, not a Response object
		console.log(data);
	})
	.catch(function(err) {
		if (err.name === fetchres.BadServerResponseError.name) {
			// just a dodgy response
			console.error(err);
		} else if (err.name === fetchres.InvalidJsonError.name) {
			// malformed json, probably
			console.error('malformed json returned');
		} else {
			// something more serious could be wrong.
			// probably want to investigate / send to
			// error aggregation service
			debugger;
		}
	});

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