I have a React component which is pulling JSON data via an axios.get call and then I am mapping an embedded object using the following function:
axios.get('MasterData.json').then(response => {
const fullTree = response.data.graph.tree;
const resultTree = Object.keys(fullTree).map(key => ({
...fullTree[key],
id: key
}));
This produces the following:
{5bd356cc-5ee6-49a0-ab68-65cbf0209105: Array(6), id: "5bd356cc-5ee6-49a0- ab68-65cbf0209105"}
which is great, but I need to add a label of "ports: to the entire nested array (Array(6)) that is being output above so that I can map it. Any help is appreciated.
({ ports : ...fullTree[key], id: key })instead of({ ...fullTree[key], id: key })