项目中我们需要获取post的数据,可以koa-bodyparser使用简化流程
安装
npm install body-parser -save
使用
var bodyParser = require('body-parser')
// POST /login gets urlencoded bodies
app.post('/login', urlencodedParser, function (req, res) {
console.log(ctx.request.body);
})
网友评论