Sorry if this question is stupid.
This code works correctly. And I just need to export data variable after all promises successfully resolved.
I cannot put t
Nowadays u do
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
async function foo() {
console.log('called')
await wait(1000)
return 'hi'
}
export default foo()
import foo from './foo'
void (async function() {
console.log(foo)
console.log(await foo)
console.log(await foo)
})()
> called
> Promise { }
> hi
> hi
It's usefull to fetch datas at start