Use Express Async Errors Instead of Try/Catch

This express-async-errors package help eliminate the need for try/catch blocks and handles everything under the hood for us. It automatically sends exceptions to error handling middleware. Less code compared to [Use Try/Catch with Async/Await].

Add in at app.js

const config = require('./utils/config')
const express = require('express')
require('express-async-errors')
const app = express()

Without try/catch block

blogsRouter.post('/', async (request, response) => {
const body = request.body
const blog = new Blog({
title: body.title,
author: body.author,
url: body.url
})
const savedBlog = await blog.save()
response.json(savedBlog)
})