[Vuejs]-How do i remove an un-needed Key from a Javascript object?

1👍

Your input data is inaccurate. You cannot have repeated keys at the same level in a JSON data structure. The below answer is with modifications to your data structure.

const data = [
  {
    ID: 1, 
    Subject: 
      {
        edge : [
          {node: {ID : 1, Title: "English"}}
        ]
      }
  }, 
  {
    ID: 2, 
    Subject: {
        edge: [
           {node: {ID: 1, Title: "Maths"}}
        ]
     }
  }
];

const result = data.map(x => ({...x, Subject: x.Subject.edge[0].node}));
console.log(result);

Leave a comment