7158550
lz最近刚接触nodejs,
使用koa写了这个 https://github.com/koajs/koa#example 例子
const Koa = require('koa');
const app = new Koa();
// logger
app.use((ctx, next) => {
const start = new Date;
return next().then(() => {
const ms = new Date - start;
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});
});
// response
app.use(ctx => {
ctx.body = 'Hello World';
});
app.listen(3000);
但每次运行都是有
assert.js:89
throw new assert.AssertionError({
^
AssertionError: app.use() requires a generator function
网上搜到了 https://github.com/alexmingoia/koa-router/issues/177 可是还是抛出同样异常
所以来请教各位大神
还有没有express经验直接学koa学习曲线怎么样?