【发布时间】:2017-11-30 16:58:55
【问题描述】:
我在通过 http.get 发送变量时遇到问题,有人可以纠正我吗?
$http.get("/product/products", { 'quantity': 5 }).then(function (resp) {
$scope.products = resp.data;
})
非常感谢
【问题讨论】:
标签: angularjs node.js angularjs-http
我在通过 http.get 发送变量时遇到问题,有人可以纠正我吗?
$http.get("/product/products", { 'quantity': 5 }).then(function (resp) {
$scope.products = resp.data;
})
非常感谢
【问题讨论】:
标签: angularjs node.js angularjs-http
您应该将其作为配置对象的params 属性发送。
$http.get("/product/products", { params: { 'quantity': 5 }})
【讨论】:
req.query
无法为get 请求发送请求正文。您可以将其更改为 POST 请求或将变量发送为 params
$http.get("/product/products", { params: { 'quantity': 5 }}).then(function (resp) {
$scope.products = resp.data;
})
【讨论】: