The function below is supposed to return an array of objects. translationByLang is returning a Promise stored then in the "result" variable. In order to map my "result" I am using Promise.all to push the values to myArray but when I console.log the value of myArray I still have an array of Promises. Note that if I console log the response inside await Promise real data are shown, not Promise data...
async function getData() {
let translationByLang = Object.values(translationArray.reduce((acc,
{field,lang,text}) => {
acc[lang] = acc[lang] || {lang}
acc[lang][field] = text
return acc
},{}))
let result = translationByLang;
if(result.length < 2){
let obj = {"lang":"en", "name":"Documento mancante","pdf_url":""}
result.push(obj)
}
let myArray=[]
await Promise.all(result).then(res => {
myArray.push(res)
});
return myArray
}