I want to write a global handler overall express ASYNC body function.
I am using
app.get('/api/0/get/whisper', (req, res) => {
res.send(a.b.c)
})
In this case, I am getting an error ReferenceError: a is not defined
and error handler working perfectly.
// error handler
app.use((err, req, res, next) => {
res.status(500).send(`Internal Server Error`)
})
How can I use this handler for ASYNC body like this:
app.get('/api/0/get/whisper', async (req, res) => {
res.send(a.b.c)
})
My error handler not working for async function. Why?
Thank you for help.