I am fetching data from different sources and have ended up with a several correctly formed json objects and one which has parent keys like below:
{
"0": {
"term_id": 3,
"name": "Burger"
},
"1": {
"term_id": 6,
"name": "Chicken"
},
"2": {
"term_id": 12,
"name": "Mexican"
},
}
How can I remove 0, 1, 2, 3 etc while also preserving other correctly structured objects? I am using lodash elsewhere in this project
This object with parent keys is being inserted into an array of multiple objects via a map
Promise.all(promises)
.then(results => {
let valueArr = [];
Object.keys(results).forEach(function(key) {
valueArr = [results[key]]
});
this.setState({ categorySelectOptions: valueArr });
})
This is a screenshot of the output with the problem:
