I have a code which converts JSON to CSV. And I put this through a specific condition ( if condition) I want the CSV to be downloaded automatically if the condition is met without any button click. what is the shortest/simplest way to do this?
For eg:
if( data.length == 10){
var stored_data = data;
data = [];
console.log(stored_data);
var csv_file = ConvertToCSV(stored_data); //ConvertTOCSV is a function
}
if the above condition is met, the CSV should be downloaded. Thank you
NOTE: I know this can e done easily with a button click. but i want the download to happen automatically when the condition is satisfied