'console.log returning undefined when trying to access array property [duplicate]
I have a return from an api in the following way
"categorias": [
{
"id": 400,
"parent_id": 281,
"ecommerce_id": null,
"categoria": "Buqu\u00eas Especiais",
"path": ["Cole\u00e7\u00f5es"],
"mercadologico": false,
"semEan": 0,
"tags": "Floricultura Online",
"pivot": { "item_id": 7518, "categoria_id": 400 }
},
{
"id": 379,
"parent_id": null,
"ecommerce_id": null,
"categoria": "Home",
"path": [],
"mercadologico": false,
"semEan": 0,
"tags": "Floricultura Online",
"pivot": { "item_id": 7518, "categoria_id": 379 }
},
{
"id": 291,
"parent_id": 281,
"ecommerce_id": null,
"categoria": "Mais Vendidos",
"path": ["Cole\u00e7\u00f5es"],
"mercadologico": false,
"semEan": 0,
"tags": "Floricultura Online",
"pivot": { "item_id": 7518, "categoria_id": 291 }
},
{
"id": 298,
"parent_id": 297,
"ecommerce_id": null,
"categoria": "Rom\u00e2ntico",
"path": ["Ocasi\u00f5es"],
"mercadologico": false,
"semEan": 0,
"tags": "Floricultura Online",
"pivot": { "item_id": 7518, "categoria_id": 298 }
},
],
I would like to access this.item.categorias.categorias.categories property
I tried with the following code, but it returns undefined
console.log(this.item.categorias.categorias)
If I try only with the
console.log(this.item.categorias)
It works, but it returns the entire array, not just the .categorias.categoria I want
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
