I want to resolve a promise and then render a view like so in 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()
}
However when I do this, the server does not send any response (browser keeps waiting for a response, and times out). What am I doing wrong?