//I think your understanding of Promises and async/await is not correct. //When you make a function async, the await keyword before a promise make sure //that code execution will pause until the promise fulfilled or rejected. //Your code can be simplified: var currentPromise; async function asyncFunc(promise){ // Do some code here return await promise; } function anotherFunction(){ asyncFunc(currentPromise); } //When we are calling return await promise, the execution engine waits in a //non-blocking way until the promise fulfilled or rejected, and then it returns //the output to the anotherFunction function.
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter