Adi
Adi3y ago

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();
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
1 Reply
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/974976116492222464 Question not getting answered? Maybe it's hard to answer, or maybe you asked at a slow time. Check out these resources for help asking a good question: https://stackoverflow.com/help/how-to-ask http://wp.me/p2oIwo-26