How to refresh the data from api in angularjs

I am getting the from API. I want to call the API after some time again so that I can display the updated data.how can i update the data after 1 minute?

use $interval:

https://docs.angularjs.org/api/ng/service/$interval

.controller('dataCtrl', function($interval){
   $scope.getData = function(){ ... }
   
  $interval(function(){ $scope.getData(); }, 1 * 1000); // 1 minute

})
2 Likes