I am currently faced with a challenge in my framework where the parent function must output either true
or
false>. However, I also need to perform an asynchronous operation within that function.</p>
<p>How can I ensure that the parent function returns <code>true
or false
after completing the async task?
An example of what doesn't work is as follows:
function parent() {
const child = new Promise();
child.then(
function (success) { return true },
)
}
The issue here is that the return statement is inside the context of the child.then() function.