- Without the Catcher
const fetch = require('fetch');
try {
const result = fetch.get('http://localhost:3000/users');
} catch (e) {
console.log(e)
}- With the catcher
const { catcher } = require('async-error-catcher');
const fetch = require('fetch');
const result = catcher(fetch.get)('http://localhost:3000/users')- For example, fetch has multiple async functions.
fetch = {
get: () => {},
post: () => {},
patch: () => {},
}const { catchers } = require('async-error-catcher');
const wrappedFetch = catchers(fetch);
wrappedFetch.get('http://localhost:3000/users');
wrappedFetch.post('http://localhost:3000/users');
wrappedFetch.patch('http://localhost:3000/users');