I am facing an issue while trying to combine 2 promises in a service. I have 2 methods - one is "UserService.getAuthenticatedUser()" which fetches the current user information, and the other is "UserService.getAccountTypeData(idUser)" which retrieves the user type information. However, in order to access the second method, I need the userID. So essentially, I first call "UserService.getAuthenticatedUser()" to get the id, and then call "UserService.getAccountTypeData(idUser)", but it's not working as expected.
function isAccount(accountName) {
UserService.getAuthenticatedUser()
.then(function (response) {
var userDetails = response.data;
});
UserService.getAccountTypeData(idUser)
.then(function (response) {
var userDetails = response.data;
return userDetails;
});
}
PS: I have already injected the service...