Hi. Yes it's a blocking call. If you want to start the asynchronous function, do some other work, then wait for the return instead you can go with something like this:
constgetPromise=()=>Promise.resolve('My return value');// the function is marked with the async keywordconstmyFunction=async()=>{// tell the interpreter we want to wait on the responsetry{// start the asynchronous functionconstmyPromise=getPromise();// Do some other workconsole.log("The function hasn't finished yet...");// Block execution till the promise has resolvedconstval=awaitmyPromise;console.log(val);// prints 'My return value'}catch(error){console.error(error.message);}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi. Yes it's a blocking call. If you want to start the asynchronous function, do some other work, then wait for the return instead you can go with something like this: