Created
February 16, 2021 09:39
-
-
Save victory-sokolov/37dbf2ba82c30a4cd072bfa210df5a14 to your computer and use it in GitHub Desktop.
Download object data to a file
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
dataToFile(content, fileName, contentType) { | |
const a = document.createElement("a"); | |
const file = new Blob([content], {type: contentType}); | |
a.href = URL.createObjectURL(file); | |
a.download = fileName; | |
a.click(); | |
} | |
dataToFile(JSON.stringify(data), 'results.json', 'application/json'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment