koa-router use 多个中间件 next is undefined
var router = new require('koa-router');
router.use(function *(next) {
// first middleware, do somethins
yield next;
});
router.use('/test', function *(next) {
// second middleware, do somethins
yield next;
});
router.use(function *(next) {
// thrid middleware, do somethins
yield next;
});
router.all('/', function () {
this.body = "hello world";
});
当我请求 /
的时候,在第三个中间件抛出异常,next is undefined
,这该怎么处理
1 回复