Answers for "nested async await"

0

nested async await

// Tell the browser that this function is asynchronous
async function myFunc() {
    // Await for the promise to resolve
    await new Promise((resolve) => {
        setTimeout(() => {
            // Resolve the promise
            resolve(console.log('hello'));
        }, 3000);
    });
    // Once the promise gets resolved continue on
    console.log('hi');
}

// Call the function
myFunc();
Posted by: Guest on April-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language