Async routes

An asynchronous route uses async / await. With Express 5, a promise rejected in a handler is automatically passed to the error handler; with Express 4, you must catch the error with try / catch and call next(err), otherwise the request is left hanging.

Example

app.get('/users', async (req, res) => {
  res.json(await listUsers());
});

Related concepts

The whole glossary