The function getInfo() reads a JSON, based on the keys passed returns an URL by making simple concatenations. I see the method returns an URL but the calling method gets the value as undefined.
function getInfo(DebugTool, ServiceName, ELBOrInstance) {
if (DebugTool == "Kibana") {
console.log("Kibana");
if (ELBOrInstance == "ELB") {
$.each( data.ServiceBlock, function( index, serviceblock ) {
if (serviceblock.Service == serviceName) {
console.log("Returning " + encodeURI(data.KibanaELBLink + data.KibanaELBSuffix.replace("ELBNAME", serviceblock.ELBName)));
return encodeURI(data.KibanaELBLink + data.KibanaELBSuffix.replace("ELBNAME", serviceblock.ELBName));
}
});
}
else {
return (data.KibanaInstanceLink + data.KibanaDaemonSuffix.replace("DAEMONNAME", serviceName));
}
}..........
}
console.log prints the right URL I need. I return the same thing to the calling method but the actual return value is undefined
console.log ("Getting " + getInfo("Kibana", key, "ELB"));
Banged my head for a bit, can't figure out.