if (CSV == '') { alert("Invalid data"); return; }
const uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
const link = document.createElement("a");
link.href = uri;
link.download = "Payments.csv";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
When i am tryinng to download the file, " link.click " is not firing not getting any console errors.
This line has an issues
document.body.removeChild(link);
You can remove it and add the below code for hiding your link from the document
link.setAttribute('style', 'display:none;');
Complete snippet code
const uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
const a = document.createElement("a");
document.body.appendChild(a);
a.href = uri;
a.download = "Payments.csv";
a.target = 'blank';
a.click();
I hope you will be clear with this info