I'm trying to use koa-bodyparser to read post parameters:
router.use(koaBody(), async (ctx: Context, next: () => Promise<any>) => {
if (
(!ctx.request.body || ctx.request.body.token != adminToken)
) {
ctx.throw(HttpStatus.UNAUTHORIZED, 'Authorization failed');
} else {
next();
}
});
Getting a type error when accessing ctx.request.body.token.