After brainstorming, I came up with this approach:
fetchCastDetails(id:number, numCast:number){
return this.getCredits(id)
.map( credits => credits.cast.length >= numCast ? credits.cast.slice(0,numCast) : credits.cast )
.subscribe(characters => {
for(let index in characters){
return this.retrievePersonData(characters[index].id);
}
});
}
retrievePersonData(person_id:number) {
return this.http.get('https://api.themoviedb.org/3/person/'+person_id+'?'+this.apiKey)
.map(response => JSON.parse(response['_body']))
}
this.mvs.fetchCastDetails(this.route.snapshot.params['id'], 6)
.subscribe( result => { console.log(result); })
However, this implementation is not functioning as expected. The error displayed in the console reads:
_this.mvs.fetchCastDetails(...).subscribe is not a function