【发布时间】:2016-06-23 17:44:37
【问题描述】:
我正在尝试从用户(.jade 页面)输入一个整数并将该值作为正文参数传递。当我尝试使用下面的代码时,该值被转换为字符串。你能帮帮我吗?
app.js
var empid = req.body.empid; // getting value from the jade page
console.log(empid); // output here is 1111
var requestdata = {1:empid};
console.log(requestdata); // output here is '1111'
var options = {
url: my URL goes here,
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
auth: {
user : username,
pass : '****'
},
body: JSON.stringify(requestdata)
}
当我尝试将其传递到 POST 请求时,我希望该值为 1111。
【问题讨论】:
标签: javascript json node.js post pug