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

95
Vistas
Create a key value par in a nested array

How do I create another key value par in a nested array that is unique in this map function? the variable data would have the key as well

let data =  props.json_logs.json_logs?.map?.((item, X) => ({
    ...item,
    id: item._id + X,
    
}));

the json_logs looks like this:

json_logs: Array(13)
0: {_id: '628905742650b2d5a1641f8f', Hostname: 'TT', Results: [{ something: 'something' },{ something: 'something'} ]}
1: {_id: '628cdc277a208e5e39c8bb80', Hostname: 'GG', Results: [{ something: 'something' }]}
2: {_id: '628cdc357a208e5e39c8bb82', Hostname: 'FF', Results: [{ something: 'something' }]}

I am trying to put an id: value pair into the Results array but also keep the other ID in the previous map function

So it shoult look like this

  json_logs: Array(13)
    0: {_id: '628905742650b2d5a1641f8f', Hostname: 'TT', Results: [{id:'628cdbb67a208e5e39c8bb7', something: 'something' },{id:'628cdbb67a208e5e39c8bb7b', something: 'something'} ]
about 4 years ago · Juan Pablo Isaza
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