Encountering Angular Error TS2339: Property 'vehicle' is not found on type 'Vehicle[]'. The error is occurring on data.vehicle.results. Any thoughts on what could be causing this issue? Is the problem related to the Vehicle model? I have attempted adding vehicle to the model but it doesn't seem to be working.
1 service
getVehicles(): Observable<Vehicle[]> {
return this.http.get<Vehicle[]>(CONSTANST.routes.vehicle.list);
}
2 component
getVehicles() {
this.priceruleService.getVehicles()
.pipe(
map(data => {
console.log("data :" , data.vehicle.results)
return data
})
)
.subscribe(data => this.vehicles = data);
}
model
export interface Vehicle {
_id: number
name: string
Type: string
Stock: string
vehicle: any
}