Koa: running code after ctx.body

Created on 17 Jan 2019  路  1Comment  路  Source: koajs/koa

app.use(async ctx => {
  ctx.body = 'Hello World';

  // running code here after response
});

how should i do ?

Most helpful comment

app.use(async ctx => {
  ctx.body = 'Hello World';

  // running code here after response
  // don't use `await` here
  someBizLogic(ctx).catch(err => {
    // handle error
  });
});
async function someBizLogic(ctx) {
  // your async biz logic
}

>All comments

app.use(async ctx => {
  ctx.body = 'Hello World';

  // running code here after response
  // don't use `await` here
  someBizLogic(ctx).catch(err => {
    // handle error
  });
});
async function someBizLogic(ctx) {
  // your async biz logic
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

usernameisalreadytaken2014 picture usernameisalreadytaken2014  路  4Comments

ke1Del picture ke1Del  路  3Comments

TheRav3n picture TheRav3n  路  3Comments

rally25rs picture rally25rs  路  4Comments

wlingke picture wlingke  路  3Comments