Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

koa get post body

const Koa        = require('koa');
const Router     = require('@koa/router');
const bodyParser = require('koa-body-parser');
const app        = new Koa();
const router     = new Router();

router.post('/', (ctx) => {
    console.log(ctx.request.body); // <== ctx.request.body
    ctx.body = 'Message received!';
});

app.use(bodyParser());
app.use(router.routes())
app.listen(3000);
 
PREVIOUS NEXT
Tagged: #koa #post #body
ADD COMMENT
Topic
Name
1+6 =