So I am running a few $http.get requests within a forloop and storing the results within an array. When I run:
console.log(episodesObj[0])
it returns undefined
. However when I run console.log(episodesObj)
it returns the whole array:
Below is the code I am running
var episodesObj = [];
for(i=1;i<=num_seasons;i++) {
$http.get('/api/show/<%=show.id%>/season/'+i)
.then(response => {
episodesObj.push(response.data)
});
}
console.log(episodesObj); ```