I would like to be able to retrieve the results from a JSON file but I cannot find the solution. I can retrieve from normal JSON but not in Object format.
Typescript
this.http.get('http://example.com/api')
.subscribe((data) => {
console.log(data);
});
The API JSON file is displayed this way:
{
1: {id:1, name: "string"}
2: {id:1, name: "string"}
3: {id:1, name: "string"}
4: {id:1, name: "string"}
}
I would like to be able to make a loop of this data afterwards
<ion-item *ngFor="let item of data" >
<div>
{{item.name}}
</div>
</ion-item>
Thank you in advance
Here is the answer to my problem:
<ion-item *ngFor="let item of data | keyvalue" >
<div>
{{ item.key }} {{ item.value['data'] }}
</div>
</ion-item>
[{id:1, name: "string"}, {id:1, name: "string"},...], anyway it would be really helpful to include in your question what you expect or want to achieve :)