I'm newbie in Angular 8 and I'm trying to implement a service to get the data in JSON format loaded into an API but I've got the following error on the console
Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
I've also been reading similar questions for this error but I'm haven't been able to solve it
Here's my .ts code where I make the service call
@Injectable({
providedIn : 'root'
})
export class CarsService {
private CarURL = 'https://catalogo-autos.herokuapp.com/api/autos';
constructor(private http: HttpClient) { }
getCars(): Observable<Car[]>{
return this.http.get<Car[]>(this.CarURL);
}
}
And here is the service:
ngOnInit() {
this.getCars();
}
getCars(): void {
this.carService.getCars().subscribe((carsTemp)=>{
this.cars = carsTemp;
})
}
Finally heres my HTML markup
<ng-container *ngFor="let car of cars">
<div class="cars">
<div class="fas fa-eye" (click)="onSelect(car,infAuto)"></div>
<div>{{car.description}} </div>
</div>
</ng-container>
I'll appreciate any further help
