After following the angular tutorial, I decided to test out the new httpClient.Get
method. However, it seems that no matter what, it always returns results of type Object
.
// HttpClient
getHeroes2 () {
this.http.get<Hero[]>(this.heroesUrl)
.subscribe((data: Hero[]) => this.takeHeros2(data));
}
takeHeros2(heroes: Hero[]) {
console.log(heroes)
}
Upon inspecting the parameter heroes
in the method takeHeros2()
, I found that it is of type Object[]
instead of Hero[]
. The result of heroes
in debugger can be seen here.
This issue is puzzling to me and I am struggling to understand why it is happening.