I want to return a .csv file that can be downloaded instead of returning a filePath. I am testing this using Postman.
const { filename, data: jsonData } = data;
const fields = Object.keys(jsonData[0]);
const json2csvParser = new Parser({ fields });
const csv = json2csvParser.parse(jsonData);
const filePath = `./public/${filename}.csv`;
fs.writeFileSync(filePath, csv);
return { path: filePath };