Answers for "err handling express"

2

express error handling

app.use(function (err, req, res, next) {
  console.error(err.stack)
  res.status(500).send('Something broke!')
})
Posted by: Guest on November-22-2020
0

err handling express

app.get('/', function (req, res, next) {
  fs.readFile('/file-does-not-exist', function (err, data) {
    if (err) {
      next(err) // Pass errors to Express.
    } else {
      res.send(data)
    }
  })
})
Posted by: Guest on May-23-2021

Code answers related to "err handling express"

Code answers related to "Javascript"

Browse Popular Code Answers by Language