I have developed a code to fetch the image information of an object inside a loop statement. However, when I print the output at the bottom of the loop, it is empty. Can anyone help me with this, please? The getMediaInfo function is an Axios call.
const postsWithImageURLS = [];
res.data.forEach(async (post) => {
const response = await getMediaInfo(post.featured_media);
postsWithImageURLS.push({...post, featured_url: response});
});
console.log(postsWithImageURLS);