Cześć.
Czytałem sobie ostatnio ten mądry artykuł: https://expressjs.com/en/guide/error-handling.html
W którym znalazłem informację:
/*Starting with Express 5, route handlers and middleware that return a Promise will call next(value)
automatically when they reject or throw an error. For example:*/
app.get('/user/:id', async (req, res, next) => {
const user = await getUserById(req.params.id)
res.send(user)
})
Niestety mój podobny kod zdaje się tak nie działać i błąd blokuje mi działanie serwera:
server.get('/query/:id', async (req, res, next)=> {
const result = await getUserData(req.params.id);
res.send(result)
})
server.listen(1236)
async function getUserData(id) {
const result = await sql.query`SELECT * FROM dbo.userss WHERE Id = ${id}`
return result.recordset[0]
}
- Zrobiłem celowo błąd: users -> userss
Czy wiecie dla czego express nie może obsłużyć tego błędu?