为什么我们做这个为什么我们在使用koa路由器时等待下一次?
router.get('/data', async (ctx, next) => {
ctx.body = dummyjson.parse(data);
await next();
});
router.get('/data/:x', async (ctx, next) => {
const newData = dataRepeat.replace('%(x)', ctx.params.x);
ctx.body = dummyjson.parse(newData);
await next();
});
什么用的await next()
它的工作而没有就好。类似的事情预计与koa 1. yield next
被添加在路由器的末尾。
[这个答案](http://stackoverflow.com/questions/10695629/what-is-the-parameter-next-used-for-in-express)是快递,不兴亚但其基本上是相同的推理。 – saadq