getActiveId
function will return me the ID
, based on the ID retuned I need to make another HTTP call to fetch the data using the function getOpenIssues
.
So in my component, I subscribed to these functions I could see the ID
is returned by getActiveId
.
I passed the ID
to getOpenIssues
function, it throws id is not defined.
After searching through net, it is not possible to access variables outside the subscribed method.
Is that case how Do i pass the ID to other function ?
Please help, I'm not able to proceed further.
Service.ts
getActiveId() {
return this.http.get<any>(apiUrl);
}
getOpenIssues(id: string) {
return this.http.get<any>(Url);
}
Component.ts
this.service.getActiveId()
.subscribe(response => this.id = response.id) // Returns ID 22407
this.service.getOpenIssues(this.id) // Should pass the ID 22407
.subscribe((response) => { })