I use the json2csv module to convert the data I have to the csv extension and send it by mail, but all the data appears in the same column. What should I do to make it appear in separate columns
this is my json2csv.js
const {Parser} = require('json2csv')
module.exports.toCsv = function(list,header){
var arr =[];
for (let i =0; i<header.length;i++){
arr.push(header[i])
}
const field = arr;
const opts = { field };
try {
const parser = new Parser(opts);
const csv = parser.parse(list);
console.log(csv);
return csv
} catch (err) {
console.error(err);
}
}
This is my sendMail.js
var mailOptions = {
from: 'abc@gmail.com',
to: 'abc@gmail.com',
subject:param,
text: 'Liste Ektedir',
attachments: [{
filename: param+'.csv',content:toCsv(groupsList,header)}
]
};
Csv file that i opened after sending mail
This is I want