filter result of observable

I have a service which returns an observable of organization object, and I want to filter the result based on organizationID I pass.

Currently I am doing something like this, but it returns me all the values instead of filtered one.

filteredOrganization(organizationId: number) {
return this.http.get<Organization[]>(this.baseUrl + '/list').pipe(
  map(organizations => {
    return organizations.filter(organization => {
      organization.id === organizationId
      return {
        id: organization.id,
        name: organization.name,
      };
    });
  }),
);

}

For Eg. service returns
[{1: abc, 2: def, 3: pqr}]

What I want
I pass 1 as organization Id and want result [{1: abc}]

What I am getting
[{1: abc, 2: def, 3: pqr}]

187 thoughts on “filter result of observable”

  1. I do not even understand how I stopped up here, however I thought this put up was once great.

    I don’t understand who you’re but certainly you’re going to a famous blogger if you happen to aren’t
    already. Cheers!

    Reply
  2. you’re actually a good webmaster. The website loading speed is incredible.

    It sort of feels that you’re doing any distinctive trick.
    Furthermore, The contents are masterwork. you have done a magnificent activity on this matter!

    Reply
  3. Have you ever thought about including a little bit more than just your articles?
    I mean, what you say is important and all. Nevertheless imagine if you added some great pictures
    or video clips to give your posts more, “pop”!
    Your content is excellent but with pics and video clips, this site could definitely be one of the most beneficial in its
    niche. Wonderful blog!

    Reply
  4. Greetings from Florida! I’m bored to death at work
    so I decided to check out your site on my iphone during lunch break.
    I really like the knowledge you provide here and can’t wait to take a look when I
    get home. I’m shocked at how quick your blog loaded on my mobile ..
    I’m not even using WIFI, just 3G .. Anyhow, good site! scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery

    Reply

Leave a Comment