0.2.4 • Published 2 years ago

async-handler-express v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Async Handler

This Package is to handle the async API response.

Installation

Use the package manager npm to install async-handler-express.

npm install async-handler-express

Add Middleware in root file

const { errorHandler }=require('async-handler-express');

#use this middleware after including routes in the app root/server file.
app.use(errorHandler);

Usage

const { catchAsync }=require('async-handler-express');

app.get('/',catchAsync(async()=>{
     await Promise.resolve();
}));

Example

#Fetch users data from jsonplaceholder fake apis 
const { catchAsync }=require('async-handler-express');

router.get('/users',catchAsync(async()=>{
     const users = await fetch("https://jsonplaceholder.typicode.com/users");
     return users;
}));

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago