koakoabodyparser使用教程

处理请求参数 koa-bodyparser

注意:引入该中间件之后,才可以正确获取到请求参数

  • 安装npm i koa-bodyparser --save
  • 使用
const koa = require('koa')
const bodyParser = require('koa-bodyparser')
const app = new koa()
app.use(bodyparser())
router.post('/test', async (ctx) => {
  let {username, pwd} = ctx.request.body
  console.log(username, pwd)
})

app.listen(3000)
原文地址:https://www.cnblogs.com/miao91/p/15732884.html