Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to call await outside async function in js

// You can't use await outside an async function. one trick to 'bypass' this limit is to use async IFEE:
const myAsyncFunction = async() => {
    return await getValue()
};

// Bypass it as follows:
let value;
(async () => {
    value = await myAsyncFunction()
})()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #call #await #async #function #js
ADD COMMENT
Topic
Name
6+8 =