Created
April 10, 2019 21:20
-
-
Save Christilut/09ed80b6250eb8f5585083d498329cb8 to your computer and use it in GitHub Desktop.
download file from string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function download (data: any, filename: string) { | |
const url = window.URL.createObjectURL(new Blob([data])) | |
const link = document.createElement('a') | |
link.href = url | |
link.setAttribute('download', filename) | |
document.body.appendChild(link) | |
link.click() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment