I have a child function that returns a string value, and it resides in a parent function. I know the GetEncCreds
function works, because the alert returned below does return the credString
value correctly. The problem I am having is when I call this function GetEncCreds
from another function, my encCreds
variable is undefined
. I'm not sure how to pass my result up to the parent function?
function GetEncCreds(domain, userName, password){
var credString = "";
genCredApi.save({
domain: domain,
userName: userName,
password: password
}).$promise.then(function (result){
credString = result.Credentials;
//This below alert works
alert(credString);
return;
})
return credString;
}
function onRdsAssociatedDocsClicked() {
var encCreds = GetEncCreds('ax-rds', 'axadmin', 'Pa$$word');
}