Я новичок ie в Angular 8, и я пытаюсь реализовать службу для загрузки данных в формате JSON
в API
, но на консоли появилась следующая ошибка
Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
Я также читал похожие вопросы об этой ошибке, но я не смог ее решить
Вот мой .ts код, где я делаю сервисный вызов
@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);
}
}
А вот и сервис:
ngOnInit() {
this.getCars();
}
getCars(): void {
this.carService.getCars().subscribe((carsTemp)=>{
this.cars = carsTemp;
})
}
Наконец-то вот моя HTML
разметка
<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>
Буду признателен за любую дополнительную помощь