Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save torbentschechne/ed8435a860073525488adeeb2f4e08c8 to your computer and use it in GitHub Desktop.
Save torbentschechne/ed8435a860073525488adeeb2f4e08c8 to your computer and use it in GitHub Desktop.
VueJs - Create & download a CSV file
//CSV contents must be in response.data.data
invoiceApi.createExport(this.dateFrom.picker, this.dateTo.picker).then(response => {
if (response.data.success == true) {
let blob = new Blob([response.data.data], {type: 'text/csv'});
let link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = 'FileName_'+this.dateFrom.picker+'_'+this.dateTo.picker+'.csv';
link.click();
this.createExportLoading = false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment