koa test4 获取post提交数据

获取post 提交数据有两种方式 ,一种是原生写法 ,一种是插件用法 。这里不讲原生只写插件用法:

安装

npm install koa-parser

导入

const bodyParser = require('koa-parser')

配置中间件

app.use(bodyParser())

获取数据

router.post('/postData',ctx=>{

      ctx.body =  await ctx.reuqst.body;

      console.log(ctx.body)

})

猜你喜欢

转载自blog.csdn.net/chao2458/article/details/85126675
koa