package
Express Error Handler for Async Functions
npm install express-async-handlerGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
4.7 kB
Includes dependencies.
Simple middleware for handling exceptions inside of async express routes and passing them to your express error handlers.
npm install --save express-async-handleror
yarn add express-async-handlerconst asyncHandler = require('express-async-handler')
express.get('/', asyncHandler(async (req, res, next) => {
const bar = await foo.findAll();
res.send(bar)
}))Without express-async-handler
express.get('/',(req, res, next) => {
foo.findAll()
.then ( bar => {
res.send(bar)
} )
.catch(next); // error passed on to the error handling route
})import asyncHandler from "express-async-handler"