Environment
Node 8.0.0
koa 2.2.0
koa-router 7.1.1
const router = require('koa-router')()
router.prefix('/logs/mobile')
router.get('/:platform', function(cxt, next) {
console.log('params', this.params);
cxt.body = { error: 'test'}
})
module.exports = router
The code is as shown above, and then access http://127.0.0.1:9901/logs/mobile/ios
and successfully obtain the return value of the body,
but this.params
isundefined
You need to use
ctx.params