Issue Ionic 2 Display Data Empty

Hello I fetch data (array) from my server and it is impossible to show the data in the app. It is empty.

this.http.post(link, dataUser)

        .subscribe(data => {
          this.dataSearch = JSON.parse(data._body).records;
               
        });

<ion-item *ngFor="#person of dataSearch" (click)="itemTapped($event)">      
       <h2>{{person.name}}</h2>
    </ion-item>   

Example in this image:


In the three rows there should be the data, but it’s empty.

  1. When you debug in google chrome (for example), is “dataSearch” empty or filled with results aka is the problem occurring before or while rendering

  2. I don’t know that way “#person of dataSearch”, I would have code that “let person of dataSearch”. Is that the same?

  1. Yes, it’s the same :wink:
1 Like

I figured it out that the problem comes from the server. The array is already empty in the server…
Can you help me with this issue?
It looks like:

{ “records”:[ {“id”:"",“name”:""},{“id”:"",“name”:""} ]}

Solved the problem with:

header(“Access-Control-Allow-Origin: *”);

1 Like