2.2.2 • Published 8 months ago

@bbc/http-transport-to-error v2.2.2

Weekly downloads
252
License
Apache-2.0
Repository
github
Last release
8 months ago

NPM downloads npm license github-issues stars forks

http-transport-to-error

Middleware convert 4XX and 5XX responses to errors

Installation

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

Usage

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
2.2.1

8 months ago

2.2.0

8 months ago

2.2.2

8 months ago

2.1.1

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago

0.0.2

7 years ago

0.0.1

7 years ago