Some issue here;
I've got an HTTP GET call, that runs in an interval every 3 seconds. The call's response data is an array of objects, and I want to log them to the console.
How can I avoid collision between intervals?
An example:
setInterval(function(){
$http.get('/some/api').then(function(dataArray){
dataArray.forEach(function(element){
setInterval(function(){
console.log(element);
},1000)
});
})
},5000)
Assume that the arrays from the api are: [1,2,3] at the first time, and [4,5,6] at the second interval, I need to see: 1 2 3 4 5 6
Thanks