Created
April 23, 2018 14:57
-
-
Save itacirgabral/ad6db6150271a4155490353483103a4f to your computer and use it in GitHub Desktop.
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
funtion download (obj) { | |
const a = document.createElement('a') | |
document.body.appendChild(a) | |
a.style = 'display: none' | |
const str = JSON.stringify(obj, null, 4) | |
const blob = new window.Blob([str], {type: 'application/json'}) | |
const url = window.URL.createObjectURL(blob) | |
a.href = url | |
a.download = 'obj.json' | |
a.click() | |
window.URL.revokeObjectURL(url) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment