I have one json file and I iterate it with map but I have a deep object key with name 'content' and I want to get specific key from it when I return my json array with map
JSON:
{ "item": [ { "title": "...", "link": "...", "content": { "_url": "How can I get this :D", ... } } ] } My javascript code:
getAllNews = async () => { const result = await this.getResource('item/') return result.map(this._transformPosts) // Here I iterate my json } _transformPosts = (item) => { return { title: item.title, link: item.link, image: item.content._url, // and here I try get _url id: item.guide, } }
item.conten._urlimage?image: (item.content && item.content._url) ? item.content._url : ''should be enough.