catch-errors

0.1.1 • Public • Published

catch-errors

Generated by OSS Project Generator.

NPM Version License

A high-order function to catch errors from promises.

Installation

Install package

$ npm install --save catch-errors

Usage

const fetch = require('node-fetch');
const catchErrors = require('catch-errors');
 
async function load(username) {
  const response = await fetch(`https://api.github.com/users/${username}`);
  const user = await response.json();
  console.log(user.name);
}
 
const wrappedLoad = catchErrors(load);
 
wrappedLoad('robertoachar');

Development

  • Cloning the repo
$ git clone https://github.com/robertoachar/node-catch-errors.git
  • Installing dependencies
$ npm install
  • Running scripts
Action Usage
Linting code npm run lint

Author

Roberto Achar

License

MIT

Package Sidebar

Install

npm i catch-errors

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

3.7 kB

Total Files

5

Last publish

Collaborators

  • robertoachar