Closed MicroDroid closed 7 years ago
Can you post a code sample please?
Thanks
// router.js
...
const koaBody = require('koa-body');
const AuthController = require('./controllers/auth');
router.post('/login', koaBody, AuthController.login);
// controllers/auth.js
module.exports = {
login: async function (ctx, next) {
console.log(ctx.request.body);
ctx.body = {
foo: 1,
};
await next();
},
}
I figured it out, it is koaBody()
not koaBody
I will PR this https://github.com/dlau/koa-body#usage-with-koa-router
Was just gonna comment, glad you figured it out!
Indeed the docs are wrong, looking forward to the pr.
Whenever I add
koaBody
as a middleware, no matter what order, koa returnsNot Found
all the time