catch-errors
v0.1.1
Published
A high-order function to catch errors from promises.
Downloads
11
Maintainers
Readme
catch-errors
Generated by OSS Project Generator.
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
|