I need to call the printNotificationsStatus() function only at the end of all api calls to be sure to have all api response but now the function is called at the end of angular.forEach execution and the API's promise can be resolved later because they are asyncronous.