const Koa = require('koa');
const app = new Koa();
app.use(async (ctx, next) => {
const start = new Date();
await next();
const ms = new Date() - start;
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});
// response
app.use(ctx => {
ctx.body = 'Hello Koa in app-async.js';
});
app.listen(3000);
报错: assert.js:85
throw new assert.AssertionError({ ^ AssertionError: app.use() requires a generator function 不应该支持es6吗?我也配了babel了啊。
"koa": "^1.2.4"
启动:node server/babel.js