I know it's a stupid question, but I've been with this for a while and I can't solve it. I am trying to access this object which is inside an Array. Specifically to url. I Tried this ways:
Doing a console.log of post.yoast_head_json.og_image the following comes out:
Array [
Object {
"height": 427,
"type": "image/jpeg",
"url": "https://www.example.es/wp-content/uploads/2022/01/pexels-picjumbocom-196656.jpg",
"width": 640,
},
]
I have already found the solution to my problem.
Solution:
let data;
const imageUrl = [];
posts.forEach ( (post)=> {
if(post.yoast_head_json.og_image != undefined)
{
data = JSON.stringify(post.yoast_head_json.og_image);
JSON.parse(data, (key, value) => {
let valueStr = String(value);
if (valueStr.includes('https')) {
imageUrl.push(valueStr);
}
})
}
});