I have an Object from which I want to extract a new array of objects so that some specific fields are at the same level.
The call returns the following:
0: Object {
id: 328,
userId: "xxx",
accountingDate: "2022-07-29T00:00:00.000+00:00",
…
}
accountingDate: "2022-07-29T00:00:00.000+00:00"
category: Object {
id: 7,
subCategories: null,
name: "Electricidad"
}
ch4: 0
co2: 0
date: null
description: null
h2o: 584795
id: 328
n2o: 0
subCategory: Object {
id: 12,
name: "Factura agua",
alcance: 1
}
alcance: 1
id: 12
name: "Factura agua"
To work with it I need the category.name and the subcategory.name .
I have made a map:
const emisionsMap = emisions.map((v)=>{
return v
})
but it returns the same.
How can I go about accessing the category.name and subcategory.name ?
If I put category.name , it gives me undefined
.
It all depends on what you want the new array to include. If only those 2 fields or all the ones that already have more than the 2 that you say in the first level.