无法从邮递员 + 节点 js 中获取帖子参数

cli*_*int 1 rest node.js express postman

我的路由文件中有以下代码:

router.post('/submit', function(req, res) {
    var email = req.body.email;
    console.log(email);
});
Run Code Online (Sandbox Code Playgroud)

我正在从邮递员那里拨打电话,并提供以下详细信息: http://localhost:3000/login/submit

参数:

email=abcxyz@gmail.com 
Run Code Online (Sandbox Code Playgroud)

和标题我都试过了

Content-Type:application/json 
Run Code Online (Sandbox Code Playgroud)

Content-Type: application/x-www-form-urlencoded
Run Code Online (Sandbox Code Playgroud)

另外,我在 app.js 中单独安装了正文解析器,并带有以下内容

var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
Run Code Online (Sandbox Code Playgroud)

但是,电子邮件的控制台日志显示“未定义”。为什么我无法使用 req.body.email 获取帖子参数。

Adi*_*iii 5

就我而言

http://127.0.0.1:3000/submit

router.post('/submit', function(req, res) {
console.log("Your Email is "+req.body.email);
res.end(); // if you not end the response it will hanging...
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

仅设置您的标题类型

Content-Type application/x-www-form-urlencoded
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

身体

在此处输入图片说明 控制台输出 在此处输入图片说明