Angular question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Angular question

I have this function inside the service that does a http get getHeroes(): Observable<Hero[]> { return this.http.get<Hero[]>(this.url + '/HeroDetails') .pipe( tap(_ => this.log('fetched heroes')), catchError(this.handleError<Hero[]>('getHeroes', [])) ); } And on the component side, when calling the function I have getHeroes(): void { this.heroService.getHeroes() .subscribe( result => { this.heroes = result as Hero[]; } );} When displaying the heroes, they are the correct count but all the data is empty. What am I missing? Thanks!

29th Feb 2020, 5:20 PM
Cristina
0 Answers