Here's the code I'm working with:
getTens.getToken($rootScope.webUserInfo[0].username).then(function(resulttoken) {
$rootScope.userInfo = resulttoken;
$sessionStorage.token = resulttoken[0].token;
$sessionStorage.userInfoStorage = $rootScope.userInfo;
CasesGroupByCaseStatus.getListing($rootScope.webUserInfo[0].username).then(function(data){
$rootScope.listingDetails = data;
$sessionStorage.listingDetailsStorage = $rootScope.listingDetails;
});
CasesGroupByCaseStatus.caseStatusCount($rootScope.webUserInfo[0].username).then(function(resultcaseStatus){
$rootScope.dashboardStatus = resultcaseStatus;
$sessionStorage.dashboardStatusStorage = $rootScope.dashboardStatus;
console.log("it is finished")
});
});
return [200, { authorizationToken: $sessionStorage.token}];
The issue I'm facing with this code is that it returns the value before completing the function. How can I ensure that the function completes first before returning the value?
This code is part of my app.js file, so I don't have access to things like scope.watch. Are there any other ways to handle this situation?