Skip to content

Instantly share code, notes, and snippets.

@adi518
Last active May 26, 2019 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adi518/883b7a3225380a9cfa39a5848c3c94c0 to your computer and use it in GitHub Desktop.
Save adi518/883b7a3225380a9cfa39a5848c3c94c0 to your computer and use it in GitHub Desktop.
const download = (fileName, data) => {
const blob = new Blob([data]);
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
a.style = "display: none";
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment