I have the following situation. I have a class. This class has an async method. Inside this async method, I have something like this :
async AsyncMethodInsideClass(){
const resquest1 = await fecth(...);
const request2 = await (request1.json())
for(const object of request2.objects){
if(object.name === "Founded"
this.newObject = object
}
}
Im trying to initialize this newObject member inside this async method. This async method is called in my class constructor.
Constructor(){
AsyncMethodInsideClass()
processNewObject(this.newObject)
}
However the processNewObject function is always being called before the AsyncMethodClass actually initializes the object, which leads to me using an undefined object inside the processNewObject. How should I solve this?
I've tried calling using await in another async function. I'm tried using then, but I really don't know the sintax to solve this. Would you please help me?