Got "Cannot read property 'url' of undefined" error when using .renderRoute
[issue link]Hi, I went into trouble when using renderRoute.
The following is what I did:
Env
Mac OS X EI Capitan 10.11.6
Node v7.7.4
5 Simple Steps
- Download nuxt-koa template
$ vue init nuxt/koa (choose koa v2)
- Install dependencies
$ yarn
- Try to run before changing anything, and it works fine
$ npm run dev # which works fine
- Change app.js to use renderRoute
// app.js
// ...
// Change the middleware to use renderRoute
app.use(async (ctx, next) => {
ctx.status = 200 // koa defaults to 404 when it sees that status is unset
// await nuxt.render(ctx.req, ctx.res)
const result = await nuxt.renderRoute('/')
console.log(result.error)
})
- Run again
$ npm run dev # error is printed
Error Message:
{ statusCode: 500,
message: 'Cannot read property \'url\' of undefined' }
Am I using renderRoute in a wrong way?
Any idea?
Thanks!