I'm trying to get the result of async
function on ngOnInit
.
On .ts file, I add this function:
async load()
{
this.picaes = await this.userService.getAffectedExpertisesPromiseSE(25);
console.log("-Inside load--------------" + this.picaes);
return this.picaes;
}
On ngOnInit, I call this async
funtion:
console.log("-Outside load--------------" + this.load());
On the file service.user.ts, I made this call:
async getAffectedExpertisesPromiseSE(id: number): Promise<any>
{
var url= `${this.baseUrl}/users/expertisesObj/${id}`;
var result= await (await fetch(url)).text();
return result;
}
That produces:
-Outside load--------------[object Promise]
-Inside load--------------[{"id":1,"name":"Angular","selected":true},{"id":2,"name":"SpringBoot","selected":true},{"id":3,"name":"Primefaces","selected":true}]
So my problem is that I can't get the result on the console Outside load.
Could you please tell me what I missed ?. Big thanks.