nuxt-community / koa-template

Starter template for Nuxt.js with KoaJS.
https://koa.nuxtjs.org
382 stars 62 forks source link

Why middleware return 'Promise' in `./server/index.js`? Where does 'resolve' and 'reject' come from? #41

Closed alanisme closed 6 years ago

alanisme commented 6 years ago

app.use(async (ctx, next) => { await next() ctx.status = 200 // koa defaults to 404 when it sees that status is unset return new Promise((resolve, reject) => { ctx.res.on('close', resolve) ctx.res.on('finish', resolve) nuxt.render(ctx.req, ctx.res, promise => { // nuxt.render passes a rejected promise into callback on error. promise.then(resolve).catch(reject) }) }) })

ghost commented 6 years ago

This issue as been imported as question since it does not respect koa-template issue template. Only bug reports and feature requests stays open to reduce maintainers workload. If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically. Your question is available at https://cmty.app/nuxt/koa-template/issues/c25.