Guides  ›  Lifecycle  ›  After response ← PREV NEXT →

After response

Use done for work after the response has been sent.

module.exports = {
  paths: '/',
  handler: function (state) {
    return 'Hello!'
  },
  done: function (state) {
    console.log({
      path: state.req.pathname,
      status: state.res.statusCode,
      ms: state.ms
    })
  }
}

Route done runs before app done, including after errors. These callbacks are not awaited; handle errors inside any asynchronous work.

Next: Validate →

Tools for business systems.