12 lines
337 B
TypeScript
12 lines
337 B
TypeScript
export default function download(url: string, filename: string) {
|
|
const link = document.createElement('a');
|
|
link.href = url;
|
|
link.download = filename;
|
|
try {
|
|
link.click();
|
|
} catch (err) {
|
|
// eslint-disable-next-line no-console
|
|
console.error(err); // Suppress redundant "Blob loading failed" error popup on IOS
|
|
}
|
|
}
|