Promise を解決してから、Koa 2 でそのようにビューをレンダリングしたいと考えています。
async function render(ctx, next) {
// wait for some async action to finish
await new Promise((resolve) => {
setTimeout(resolve, 5000)
})
// then, send response
ctx.type = 'text/html'
ctx.body = 'some response'
await next()
}
ただし、これを行うと、サーバーは応答を送信しません (ブラウザーは応答を待機し続け、タイムアウトします)。私は何を間違っていますか?