I am developing an application with AngularJS and I have an array of data that I need to loop through and make multiple ajax requests. Once all of the data has been returned for all of requests I would then like manipulate the returned data.
However, when I log compositeSchedule, I get "[]". How can I make all of the requests, then access the compositeSchedule array to manipulate the data?
var compositeSchedule = [];
$.each(activeTeams, function(i){
var params = {};
params.teams = activeTeams[i].ID;
params.org = org.URL;
params.sessionID = org.user.sessionID;
$http.get("https://api.domain.com", {params: params}).then(function(result){
compositeSchedule = compositeSchedule.concat(result.data.Events);
});
});
console.log(compositeSchedule);