Closed wlingke closed 7 years ago
For this simple koa2 server:
app.use(async (ctx, next) => { next(); }); app.use(bodyParser({ enableTypes: ['json'] })); app.use(async (ctx) => (ctx.status = 200));
Client calls:
fetch('/', {method: 'post', headers: {'Content-Type': 'application/json'}})
The return is status 404 - Not Found.
If I change the first middleware by adding await:
await
app.use(async (ctx, next) => { await next(); });
then it works as expected.
same here. Only works with Content-Type: text/plain
Content-Type: text/plain
you must add yield before next() here, because bodyparser is asynchronous.
yield
next()
For this simple koa2 server:
Client calls:
The return is status 404 - Not Found.
If I change the first middleware by adding
await
:then it works as expected.