req.query:get请求;

req.body:post请求;

(1) get请求:

req.query;

 (2) post请求:

     第一步:下载body-parser模块

npm install body-parser --save-dev

     第二步:引入body-parser模块

const bodyParser = requier("body-parser");

     第三步:使用body-parser模块

app.use(bodyParser.urlencoded({ extended: false }));

     第四步:使用body-parser模块的参数json方法

app.use(bodyParser.json());

     第五步:获取参数

req.body;

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐