Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

238
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda