这是我第一次使用节点 js。我正在通过 Postman 发送邮寄请求。问题是我无法获得这些参数。它说未定义或为空
这是我迄今为止尝试过的
var express = require("express");
var app = express();
var bodyParser = require('body-parser')
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
// support encoded bodies
app.listen(3000, () => {
console.log("Server running on port 3000");
});
app.post('/login',function(req,res){
console.log('request =' + JSON.stringify(req.body))
console.log(req.body);
var user_name=req.body.user;
var password=req.body.password;
res.send(req.body);
console.log("User name = "+user_name+", password is "+password);
res.end("yes");
});
快递版本是 4.16.4
这是控制台上显示的内容