1

我正在尝试进行多次 $http 后调用,我的代码如下所示:

var data = [{"id": 1, "Name": A}, {"id": 2, "Name": B},...];
var requests = [];
angular.forEach(data, function(value) {
    requests.push($http(
       url:'/example.com', 
       method: "POST", 
       dataType: 'json', 
       contentType:'application/json', 
       data:value ))
    });
$q.all(requests).then(function(results){
    results.forEach(function(data,status,headers,config){
        console.log('success');
    })
})

这工作正常,但是当数据数组的长度更多时,来自客户端的服务调用次数很高。所以我想把它作为一个批处理请求。我无法为 POST 操作的批处理请求找到任何适当的文档。请帮助我。

4

0 回答 0