Last active
March 25, 2020 06:06
-
-
Save PedroAlvesV/7aad0d14e013009b7226785c2bf775f4 to your computer and use it in GitHub Desktop.
js-snippets
This file contains hidden or 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
function download(content, fileName, contentType) { | |
var a = document.createElement("a"); | |
var file = new Blob([content], {type: contentType}); | |
a.href = URL.createObjectURL(file); | |
a.download = fileName; | |
a.click(); | |
} | |
download(JSON.stringify(jsonData), 'json.txt', 'text/plain'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment