I have a program that returns true or false correspondingly based on the result of an asynchronous function someAsyncFunction(), which looks like the follow:
function getResult(param) {
someAsyncFunction(param).then((result) => {
if (result == 1) {
console.log('breakpoint 1');
return true;
} else {
console.log('breakpoint 2');
return false;
}
}
}
In the client file, I call the function as follow
const result = getResult(11);
console.log(result);
It seems that someAsyncFunction was able to function properly. The console prints 'breakpoint 1' or 'breakpoint 2' correspondingly based on the input param. However, the result printed is always undefined. Any ideas?