http从angularangular色向node.js服务器发送密码
这正在扰乱我。 我知道我可以做到以下几点:
$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中的任何地方find数据。 我在这里做错了什么?
你可以find:
- 在
req.body
上req.body
数据 - 在
req.query
上获取参数 - 在
req.params
参数
req.body.userName为你的例子