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'} ]