Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

koa2和generator问题

$
0
0
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 untitled1.png不应该支持es6吗?我也配了babel了啊。

"koa": "^1.2.4"

启动:node server/babel.js

Viewing all articles
Browse latest Browse all 14821

Trending Articles