0

I have an object in which at index 0 has an array. Inside the array I have two objects. Using map function at obj[0] result is undefined. How can I access it?

enter image description here

  function getRowData() {

    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 promises=[]
      Promise.all(result).then(res => {
      promises.push(res)
    });
    return promises  

  }

  const obj = getRowData();
  console.log('typeof', typeof obj, ', obj', obj)

0 Answers0