I'm using this method to get the data:
home.service.ts
getHomes(): Observable<HomeApi> {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
'token': `${this.global.token}`
})
};
return this.http.get<HomeApi>('url', httpOptions);
}
home.component.ts
ngOnInit() {
this.service.getHomes().subscribe((res: HomeApi) => this.home = {
images: res['images']
});
}
home.component.html
<div *ngFor="let item of home.images">{{item.name}}</div>
Now item.name work great, but in console throws this error:
ERROR TypeError: Cannot read property 'images' of undefined
Here is the Sample
console.log(res)and check what is being returned?