I am trying to implement a service which makes a rest call every 5 seconds. Previously I was using $interval but I realized using could get in troubles if a request takes longer than 5 sec because of internet connection problems.
service.fetchData= function () {
//UpdateHandler is my handler function which just fills my json array
restApiService.requestFromApi("REST" + '?latitude=' + latestCoords.latitude + '&longitude=' + latestCoords.longitude + '&radius=' + config.radiusInMetres, updateHandler);
};
$timeout(service.fetchData, 5000);
fetchData is still called just once.
How can we use timeout for multiple calls and using promises(I am not very familiar with promises)