Trying to call a list of apis obtained from first api call
loadData() {
this.http.get(this.firstApi).pipe(
.map(response => response.ip)
)
.subscribe(ip => {
console.log(ip);
Observable.forkJoin(
ip.map(
g =>
this.http.get('http://'+ip+':port/api/status')
.map(response => response.json())
)
).subscribe(res => {
//THIS WILL LOG GAME RESULTS SUCH AS HITS/PITCHES/STOLENBASES/RUNS...
let i;
res.forEach((item, index) => {
i = index;
console.log(res[i]);
})
})
});
}
The issue is that ip is undefined. Any way to solve the issue.
Generally what I need is
Call an api -> returns list of object with ip key and other stuff (ip is relevant). Call status api (returns a json object) in each of the ip obtained and push the result to an array.
ipis undefined then debugresponse, it might not haveipas a direct keyipproperty. It only has alengthproperty. So response.ip doesn't make sense if response is an array. Everything would be so much clearer if you defined and specified types:this.http.get<Array<{ip: string;}>>