Table only returning first letter

Table only returning first letter

PosegPoseg Posts: 1Questions: 1Answers: 0

Hi, i'm currently learning javascript. I have a project for testing purpose, i wanted to setup mongodb as the data source and use datatables as to display the data on electron framework. So electron, mongodb, datatables combined.

async function getName() {
  let result = []
  try{
  const name = await loadCollection()
    await name.aggregate({$match: {founded_year:2010}},{$group : {_id:"$name"}}).forEach(function(u) { result.push(u.name) })
  }
  catch(e){
    console.log(e)
  }
  console.log(result)
  return result
}

let datas = getName().then(function(x){
  $('#table1').DataTable({
  data : x
})})

I have had a success on connecting those 3 modules. However, datatables is only getting the first letters of each data. here as you can see, in the console log my function outputs the array correctly which i believe means that there is nothing wrong with the backend. I can't find where the problem is. Hoping to get answers from you guys soon! Thank you

This discussion has been closed.