AdiA
Reactiflux4y ago
Adi

Adi – 10-07 May 14

Can I have async method which is used in constructor for intialization? something like this:
class Foo {
  constructor () {
        this.initialize();
    }

    async initialize () {

        const res = await randomMethod();
        const res2 = await randomMethod2();
        
    }
}
const bar = new Foo();
Do I need to use
await this.initialize();
I checked the code without await also it is working
Was this page helpful?