mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-03-26 07:39:16 +03:00
13 lines
441 B
TypeScript
13 lines
441 B
TypeScript
|
export const saveCsv = ({ document }: Window, csv: string, filename: string) => {
|
||
|
const link = document.createElement('a');
|
||
|
const blob = new Blob([ csv ], { type: 'text/csv;charset=utf-8;' });
|
||
|
const url = URL.createObjectURL(blob);
|
||
|
|
||
|
link.setAttribute('href', url);
|
||
|
link.setAttribute('download', filename);
|
||
|
link.style.visibility = 'hidden';
|
||
|
document.body.appendChild(link);
|
||
|
link.click();
|
||
|
document.body.removeChild(link);
|
||
|
};
|