@bbc/http-transport-to-error

    2.1.1 • Public • Published

    NPM downloads Build Status 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
    

    Keywords

    none

    Install

    npm i @bbc/http-transport-to-error

    DownloadsWeekly Downloads

    306

    Version

    2.1.1

    License

    Apache-2.0

    Unpacked Size

    6.19 kB

    Total Files

    11

    Last publish

    Collaborators

    • johnnewman
    • ibl
    • niklasr
    • hjerling
    • simontanner
    • jessicabergsbbc
    • simongregory
    • andymsukbbc
    • tomfranciswinnington
    • magdalena.glanc
    • tonymcbeth
    • zdhz