I want following output ["a","b"] out of loop but isnot getting. How can I do it? instead of getting [].
post_with_medias(text, medias) {
var listOfIds = []
medias.forEach((element) => {
this.upload_media(element).then((res) => {
// we can assign alt text to the media, for use by screen readers and
// other text-based presentations and interpreters
var a = res.data
listOfIds.push(a) // returns ["a","b"]
})
console.log(a); // this doesnot give the data appended returns []
})