So i have this code
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}];
In my code, i want it to complete the function first before returning the value but what happens is that it fires the return first wtout running the function, How do i handle this?
This code is my app.js. So i cant do stuffs such as scope.watch and all.