hard20 pts · first answer countsnodejsexpresserror-handling
Async error skips Express handler
This app runs Express 4 on Node 22, and loadReport() rejects. What happens?
app.get('/report', async (req, res) => {
const data = await loadReport()
res.json(data)
})
app.use((err, req, res, next) => {
res.status(500).json({ error: 'Something went wrong' })
})Discussion 0
Join free to post in the discussion.
Related questions
- Empty req.body in ExpressFull Stack Developer
- try/catch around an async callFull Stack Developer
- Why commit the lockfileFull Stack Developer
- What ^3.22.4 allowsFull Stack Developer
- One failing widget breaks the dashboardFull Stack Developer
- Returning form validation errorsFull Stack Developer
- Webhook signature always failsFull Stack Developer
- One report slows every requestFull Stack Developer