I have these of functions:
ngOnInit(): void {
this.getObj();
}
public getObj():any{
this._callAPI1.getList().subscribe(
async res => {
let temp = await this.getPrograms(res.current_subscription_id);
console.log(temp);
},
err => {
}
)
}
public getPrograms(id):any{
this._callAPI2.getPrograms(id).subscribe(
resProgram => {
console.log(resProgram);
return resProgram;
},
err => {
}
)
}
The problem is that in the first function called getObj
the response of the console log is Undefinded
when I call the function getPrograms
. The things is that the console inside in the getPrograms
function returns a good response. I tried to add the property await
but it still does not works.
Any suggestion ??
CodePudding user response:
Try removing both async
and await from the getObj
function.
Then report back here in comment of this answer.
ngOnInit(): void {
this.getObj();
}
public getObj():any{
this._callAPI1.getList().subscribe(
res => {
let temp = this.getPrograms(res.current_subscription_id);
console.log(temp);
},
err => {
}
)
}
public getPrograms(id_subs):any{
this._callAPI2.getPrograms(id).subscribe(
resProgram => {
console.log(resProgram);
return resProgram;
},
err => {
}
)
}