I am new to node.js. I have to email the retrieved data in CSV format. I wrote code and it is working fine but with an empty array the headers are not included in the CSV, I get an empty excel sheet.
I used
var fastcsv = require("fast-csv");
var format = require('@fast-csv/format');
var csv = fastcsv.write(finalData, {headers: true});
I tried the code below, but it gives me the "format is not a function" error
var csv = fastcsv.write(finalData, {headers: true});
var csv = csv.format({alwaysWriteHeaders:true})
please help