Closed mustafaekim closed 6 years ago
I am getting 404 when posting to /signup If I remove the bp (bodyParser middleware), it returns 200
Why is that?
import Koa from "koa"; import Router from 'koa-router'; import bodyParser from "koa-bodyparser"; export const public_router = new Router(); async function sign_up(ctx: Koa.Context, next: Function) { console.log("Signing up...") console.log(ctx.request.body) //console.log(ctx.request.rawBody) ctx.body = { name: "test" } //ctx.request.body } var bp = bodyParser({ onerror: function (err, ctx) { ctx.throw('body parse error', 422); } }) //public_router.use(bp); public_router .post("/signup", bp, sign_up)
if I use app.use(bp) than it works again
sorry my bad! A previous middleware didnt call await before next() ....
I am getting 404 when posting to /signup If I remove the bp (bodyParser middleware), it returns 200
Why is that?