Calling async functions in QuokkaJS
1 min read

Calling async functions in QuokkaJS

In the TypeScript file, write your async function and call it using an immediately-invoked async arrow function. Here's an example.



async function getNumber(){
    return await new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(1);
        }, 1000);
    });
}

(async () => {
    const num = await getNumber();
    console.log(num);
})();