unable to get the async opertion done and sync its object/instance of the class.
class A {
constructor() {
this.init()
}
async init() {
const p = new Promise((res, _) => {
res(10)
})
this.data = await p
console.log('this from A', this) // B { data: 10 }
// want this data should update my child's 'this'
}
}
class B extends A {
constructor() {
super()
}
}
const b = new B()
console.log({ b }) // B {}
i did tried: Async/Await Class Constructor
but no one has a solution if class extends some other class.
what can be the best way to do so.