This example return 404.
const Koa = require('koa');
const app = new Koa();
app.use(ctx => {
setTimeout(function () {
ctx.body = 'Hello Koa';
}, 1000);
});
app.listen(3000);
try
app.use(ctx => new Promise(resolve =>{
setTimeout(function () {
ctx.body = 'Hello Koa';
resolve()
}, 1000);
}));
why
try
app.use(ctx => new Promise(resolve =>{ setTimeout(function () { ctx.body = 'Hello Koa'; resolve() }, 1000); }));
owing to what? event-loop?
Most helpful comment
try