以下代码,koa 会返回什么数据
更多描述 根据有无
await next()
判断以下代码输出结果
const Koa = require("koa");
const app = new Koa();
app.use(async (ctx, next) => {
ctx.body = "hello, 1";
});
app.use((ctx) => {
ctx.body = "hello, 2";
});
app.listen(3000);
const Koa = require("koa");
const app = new Koa();
app.use(async (ctx, next) => {
ctx.body = "hello, 1";
await next();
});
app.use((ctx) => {
ctx.body = "hello, 2";
});
app.listen(3000);
const Koa = require("koa");
const app = new Koa();
app.use(async (ctx, next) => {
await next();
ctx.body = "hello, 1";
});
app.use((ctx) => {
ctx.body = "hello, 2";
});
app.listen(3000);
Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 238
Author 回答者: shfshanyue
根据 koa 的洋葱模型,返回结果是
hello, 1
hello, 2
hello, 1