Created
June 13, 2023 15:05
-
-
Save gonaumov/d96bc272211a799fff9ae255408a9393 to your computer and use it in GitHub Desktop.
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
// imagine this is the place where you usually | |
// get the response in the normal application | |
// you need just to pass here result variable | |
// it will create a .txt file with the json | |
// and download it. You need just to reuse this | |
// mock file later. | |
const element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(results, null, ' '))); | |
element.setAttribute('download', 'data.txt'); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment