I have a javascript function as following
async function createGrid(data){
let textArray = [];
var lang = "eng";
data.map(async obj => {
await getTranslatedText(lang, obj.type).then(res =>{
textArray.push(res);
});
});
console.log(textArray);
}
and also getTranslatedText return a string value.
from the console log below it will print the array as empty. When I extract it, it will show us the data in it.
Can anyone explain what is happening here and how we can get the values?