Use Try/Catch with Async/Await
For error handling with async/await, the recommended method to deal with exceptions is using try/catch method. The catch block calls next function and passes request handling to error handling middleware.
blogsRouter.post('/', async (request, response, next) => { const body = request.body const blog = new Blog({ title: body.title, author: body.author, url: body.url }) try { const savedBlog = await blog.save() response.json(savedBlog) } catch(exception) { next(exception) }})
Above option is good when using a library is not an option. For cleaner code -> [Use Express Async Errors Instead of Try/Catch]