gpt4 book ai didi

angularjs - http 将密码从 Angular 发送到 Node.js 服务器

转载 作者:太空宇宙 更新时间:2023-11-03 22:12:16 25 4
gpt4 key购买 nike

这让我很烦恼。我知道我可以执行以下操作:

$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.body 上发布数据
  • req.query 上获取参数
  • req.params 上的路由参数

示例的req.body.userName

关于angularjs - http 将密码从 Angular 发送到 Node.js 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38825595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com