Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //codice che non funziona
- this.carsService.getCars().pipe(
- filter(car => car.userId == this.userId)) // Property 'userId' does not exist on type 'Car[]
- .subscribe( cars => {
- console.table(cars);
- })
- //soluzione
- this.carService.getCars().pipe(
- map(cars => cars.filter(car => car.userId == this.userId))
- .subscribe( cars => {
- console.table(cars);
- })
- //carsService.ts
- getCars(){
- let options = {headers:this.headers}
- return this.http.get<Car[]>(this.host + 'getCars', options);
- }
- // Car model
- export class Car {
- username:string;
- id:number;
- model:string;
- brand:string;
- userId:number;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement