Socket
Socket
Sign inDemoInstall

@bbc/http-transport-to-error

Package Overview
Dependencies
Maintainers
20
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbc/http-transport-to-error

Converts 4XX and 5XX responses to errors


Version published
Weekly downloads
513
increased by48.27%
Maintainers
20
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 29 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc