Skip to content

Instantly share code, notes, and snippets.

@sploders101
Last active June 23, 2020 21:11
Show Gist options
  • Save sploders101/597b98abe2aff7d7f5055f95f7e3cd62 to your computer and use it in GitHub Desktop.
Save sploders101/597b98abe2aff7d7f5055f95f7e3cd62 to your computer and use it in GitHub Desktop.
Simple function for downloading text
function downloadString(str, name) {
const elem = document.createElement("a");
elem.href = URL.createObjectURL(new Blob([str]));
elem.download = name;
elem.click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment