diff --git a/src/app/films/films.component.ts b/src/app/films/films.component.ts index 7e18316..4f8da46 100644 --- a/src/app/films/films.component.ts +++ b/src/app/films/films.component.ts @@ -21,11 +21,13 @@ export class FilmsComponent implements OnInit { } showCharacters(film){ + let promiseArray = []; film.characters.forEach((characterUrl) => { - this.http.get(characterUrl) - .toPromise() - .then(response => this.selectedFilmCharacters.push(response.json())); + promiseArray.push(this.http.get(characterUrl).toPromise()); }); + Promise.all(promiseArray).then(values => { + this.selectedFilmCharacters = values.map(value => value.json()); + }) } ngOnInit() {