I have successfully managed to unparse a json to csv using papaparse. I have stored the generated csv in a variable. On a button click, the csv is being generated and I can see the result in my console. I want to download that csv generated into my local system when I click the button. How do I do that?
const csv = Papa.unparse(csvData);
Try this code
var csv = Papa.unparse(array);
var csvData = new Blob([csv], {type: 'text/csv;charset=utf-8;'});
var csvURL = window.URL.createObjectURL(csvData);
var testLink = document.createElement('a');
testLink.href = csvURL;
testLink.setAttribute('download', 'test.csv');
testLink.click();