【发布时间】:2016-08-08 09:28:12
【问题描述】:
这让我很烦。我知道我可以做到以下几点:
$http.post('https://url:8080/api/registerUser?username=' + usrName + '&usrPassword=' + usrPassword);
但我猜这不是向服务器传递密码的正确方法。所以我试过这个:
$http({
method: 'POST',
url: url2,
data: {
userName: encodeURIComponent(usrName),
userPassword: encodeURIComponent(usrPassword)
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
但是当我收到它时,我在 node.js 中的 req 上的任何地方都找不到数据。我在这里做错了什么?
【问题讨论】:
-
如果出现错误,请检查浏览器控制台
-
我没有收到任何错误
-
req对象上根本找不到数据
-
在客户端试试这个并检查是否真的被编码。 console.log(encodeURIComponent(usrPassword))
-
切换到
https协议
标签: angularjs node.js http-post