I want to call an several async functions in useEffect)
, but I am not sure how to include the await
keyword to await their results
// somewhere else func1 and func2 are defined
async function func1() {...};
async function func2() {...};
// func1, func2 are imported into file of functional Component
...
useEffect(() => {
async function foo() {
func1();
};
async function bar() {
func2();
}
if (...) {
await Promise.all([foo(), bar()]);
...
}
...
}, [])
...
This gives me
Unexpected reserved word 'await'
How to await
async functions in useEffect()
?