# @bbc/http-transport-to-error

> Converts 4XX and 5XX responses to errors

Latest version **2.2.2** (published 2023-09-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @bbc/http-transport-to-error
pnpm add @bbc/http-transport-to-error
yarn add @bbc/http-transport-to-error
bun add @bbc/http-transport-to-error
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2023-09-29 |
| First published | 2017-09-05 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | kieranjoyce, monsai, rosemcnally, felixmercermoss, katyasa, dwalker487, amitsavant, remotecharms, npmbs, vaughr03, iuketaylor, jamiebower185, benjwheeler, onlyonehas, drrobharper, johnnewman, ibl, simontanner, simongregory, tonymcbeth |

## Links

- npm: https://www.npmjs.com/package/@bbc/http-transport-to-error
- Repository: https://github.com/bbc/http-transport-to-error
- Issues: https://github.com/bbc/http-transport-to-error/issues
- npm.io page: https://npm.io/package/@bbc/http-transport-to-error

## Recent versions

- 2.2.2 (latest) — 2023-09-29
- 2.2.1 — 2023-09-29
- 2.2.0 — 2023-09-28
- 2.1.1 — 2019-02-13
- 2.0.1 — 2018-04-18
- 2.0.0 — 2018-02-26
- 1.0.0 — 2017-11-21
- 0.0.2 — 2017-09-14
- 0.0.1 — 2017-09-05

## README

[![NPM downloads](https://img.shields.io/npm/dm/@bbc/http-transport-to-error.svg?style=flat)](https://npmjs.org/package/@bbc/http-transport-to-error)
![npm](https://img.shields.io/npm/v/@bbc/http-transport-to-error.svg)
 ![license](https://img.shields.io/badge/license-MIT-blue.svg) 
![github-issues](https://img.shields.io/github/issues/bbc/http-transport-to-error.svg)
![stars](https://img.shields.io/github/stars/bbc/http-transport-to-error.svg)
![forks](https://img.shields.io/github/forks/bbc/http-transport-to-error.svg)

# http-transport-to-error

> Middleware convert 4XX and 5XX responses to errors

## Installation

```
npm install --save @bbc/http-transport-to-error
```

## Usage

```js
Convert any response equal to or greater than 400 to errors: 

const url = 'http://example.com/404';
const HttpTransport = require('@bbc/http-transport');
const toError = require('@bbc/http-transport-to-error');

const client = HttpTransport.createBuilder()
   .use(toError())
   .createClient();

  try {
    await client.get(url).asResponse();
  } catch (err) {
    console.error(err);    
  }
});
```

## Test

```
npm test
```

To generate a test coverage report:

```
npm run coverage
```

---
_Source: https://npm.io/package/@bbc/http-transport-to-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
