angular-http-batcher
angular-http-batcher copied to clipboard
BatchRequestManager sendFn - $digest error.
I keep getting a digest error when this function runs. I added a timeout to make sure the digest is completed prior to running the callback function. Would you consider adding this timeout to the batcher?
function sendFn() {
var self = this,
adapter = self.getAdapter(),
httpBatchConfig = adapter.buildRequest(self.requests, self.config);
self.sendCallback();
self.$injector.get('$http')(httpBatchConfig).then(function (response) {
var batchResponses = adapter.parseResponse(self.requests, response, self.config);
//timeout I inserted.
self.$timeout(function() {
angular.forEach(batchResponses, function (batchResponse) {
batchResponse.request.callback(
batchResponse.statusCode,
batchResponse.data,
convertHeadersToString(batchResponse.headers),
batchResponse.statusText);
});
},0,true);
}, function (err) {
angular.forEach(self.requests, function (request) {
request.callback(err.statusCode, err.data, err.headers, err.statusText);
});
});
}