'Filter elements of an Observable<Array<Payload>>

I have these posts that are displaying as cards.

  posts: Observable<Array<TripPayload>>;

    export class TripPayload{
    id: String;
    content: String;
    title: String;
    price:Number;
    check_in_date:String;
    check_out_date:String;
    city:String;
    state:String;
    country:String;
}

I want to filter them by the attributes of TripPayload (city,country,price...) but I don't know how to access them. I made some filters in the backend but if I want to apply a second filter after applying one, I get 0 posts. I've seen some good filters using MatTableDataSource, but I think I can not apply them in these case.

  filterPostsByLocation()


{
    this.posts = this.addPostService.filterPostsByLocation(this.country,this.state,this.city);
  }


Solution 1:[1]

Use Map or Pluck operator according to ur req. below is sample

filterPostsByLocation (): Observable<Recipe[]> {
    return this.http
        .get<Recipe[]>(this.locationURL)
        .pipe(map(res =>`${res.country}${res.state}${res.city}`));
}

https://chebbi-lamis.medium.com/rxjs-pluck-a-pound-of-pluck-is-worth-a-ton-of-map-f7cc600db371

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RED.Skull