I have an array. While I loop thru array, I compose request and make http calls. But I want each of that http PUT requests to be made within 16 second gap. I tried n number of ways. I tried to wrap http.then with $timeout, $interval to loop 1 time, added timeout:16000 to http config. None of them are delaying http put call. Only first call in the loop in delayed. How do I delay every every actual http call by 16 seconds? Here is my code. I added timeout in http config as well as $timeout. I tried with one at a time, both. None worked
angular.forEach($scope.provisionDataArray, function(provReq, index) {
var userProvisionSCIMUrl = someurl;
scimProvReq = prepareProvisionRequestJSON(provReq, $scope.refData, $scope.App);
var scimReq = {
method: 'PUT',
url: someurl,
headers: {
'Content-Type': 'application/json'
},
timeout: 16000,
data: scimProvReq
}
$timeout(function() {
$http(scimReq).then(function successCallback(response) {
var provStatus = {};
provStatus.reqNum = index;
provStatus.nbid = response.data.id;
provStatus.id = response.data.request.id;
provStatus.status = response.data.request.status;
provStatus.statusMessage = response.data.request.statusMessage;
$scope.provisionStatus.push(provStatus);
},
function errorCallback(response) {
$scope.errors.push({
error: "Error processing,
line: index
});
});
},16000,$scope.provisionDataArray.length)
}
});