Remove property/key from javascript array of objects but keep object

I have an array as follows:

array = [{data:[{field1: blah, field2: blah, field3: blah}]},{data:[{field1: blah, field2: blah, field3: blah}]}]

I want to remove data such that my array of objects has to tag such as follows:

array = [{field1: blah, field2: blah, field3: blah},{field1: blah, field2: blah, field3: blah}]

I know I can loop through but is there a way to use array.map or some shortcut?

Answer

Yeah array.map() should do the trick:

const originalArray = [{
  data: [{
    field1: "blah",
    field2: "blah",
    field3: "blah",
  }]
}, {
  data: [{
    field1: "blah",
    field2: "blah",
    field3: "blah",
  }]
}];

const mapFunction = ({ data: [obj] }) => obj;

const newArray = originalArray.map(mapFunction);

console.log(newArray);