express middleware error code example
Example 1: express error middleware
function errorHandler (err, req, res, next) {
if (res.headersSent) {
return next(err)
}
res.status(500)
res.render('error', { error: err })
}
Example 2: put route error express
//don't forget the "/" in the route targeted URL :
app.put("/collection/:id", (req, res)=>{
//route content
})