DEV Community

Melanie-Koeln
Melanie-Koeln

Posted on • Edited on

http.get - different data structure

Hey,

I'm trying to download data from a server using http.get.

For testing I'm using the tour of heroes tutorial. I changed the url to another local source.
The data looks like this:
{
"current":1, "total":2,"rows":[
{"field1":1000,"field2":"test1"},
{"field1":1001,"field2":test2"}
}
Of course, the code cannot run like this. How can I tell angular to use the rows? Is there a option in the http.get? In the tutorial the command was:
getHeroes(): Observable {
return this.http.get(this.heroesUrl)
}

Another possibility could be to adjust the data later. Perhaps here:
getHeroes(): void {
this.heroService.getHeroes()
.subscribe(heroes => this.heroes = heroes );
}

Thank you very much for your help in advance :).

Melanie

edit:
Received following message in the browser (Entwicklungtools):
core.js:6162 ERROR Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed

The datatype may not be right?

Top comments (0)