Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
angular and rxjs - removing properties from object

I have an endpoint that returns the following object properties:

{
  "id": "1",
  "department": "sample",
  "address": "sample",
  "email": "sample@email.com",
  "products": [
    {
      "id": "100",
      "product_type": "A",
      "product_category": "sample",
      "category": "sample"
    },
    {
      "id": "101",
      "product_type": "A",
      "product_category": "sample",
      "category": "sample"
    }
  ]
}

I'm doing like this on Angular

this.httpService.get<Product>(<my_endpoint>).pipe(map(response => response.data))

I need to remove all the properties product_type from the array of objects and keep the rest intact. I can't find if is possible to do this with only RxJs library filtering capabilities.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Inside your map function do this:

map((response) =>{ 
let data = response.data;
let products = data.products;

products =products.map((product) =>{ 
delete product['property1'];
return product; // without deleted properties;
}) 
data.products =products ;
return data;
})
about 4 years ago · Juan Pablo Isaza Report

0

You can use RxJS pluck and map, as well as array map and object destructuring to remove the un-needed property.

this.httpService.get<Product>(<my_endpoint>).pipe(
   pluck('data'),
   map( data => {
     const products = data.products.map( p => {
       const {product_type, ...others} = p;
       return {
          ...others
       }
     });
     return {
       ...data,
       products
     }
   })
)

Note: don't use delete on objects if you can avoid it (it mutates the object)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!