I'm doing a project and I keep getting the error Error trying to diff '[object Object]'. Only arrays and iterables are allowed I looked up the error and there are two ways to do it, change the incoming data(no possible) or "transform the object in my component". I need to do the latter, but I can't find any way how to as I'm only a student. Here's some of the relevant code:
characters.ts
apiUrl = 'https://swapi.co/api/people';
getUsers() {
return new Promise(resolve => {
this.http.get(this.apiUrl)
.subscribe(data => {
resolve(data);
}, err => {
console.log(err);
});
});
home.ts
users: any= [];
constructor(public navCtrl: NavController, public restProvider:
CharactorsProvider) {
this.getUsers();
}
getUsers() {
this.restProvider.getUsers()
.then(data => {
this.users = data;
console.log(this.users);
});
}
home.html
<ion-list>
<ion-item *ngFor="let user of users">
<p>{{charactor.results}}</p>
</ion-item>
</ion-list>
</ion-content>
Please any help with changing the code would be a huge help. I'm new to Ionic, only a few weeks in, and have a basic knowledge of it.
Edit: Code not in boxes. Edit 2: API I'm using https://swapi.co/api/people/
console.log(this.users)output?