When dealing with a situation where a function does not always return a promise, how can it be best handled? The complexity of my current code prevents me from providing a detailed explanation, but essentially, the issue involves checking a condition and then either returning a local variable or initiating an ajax request. Here is an example:
function sample(value){
if(!value){
return $http.get('www.sample.com');
}
else {
return "Your value is "+value;
}
}
Is there a way to determine if the returned value from the function is a promise that requires resolution? Alternatively, is there another approach available for handling such scenarios? Your input is greatly appreciated!