Skip to content

Instantly share code, notes, and snippets.

@usayamadx
Created September 16, 2021 02:03
Show Gist options
  • Save usayamadx/c76b6cd55bff968225cf1e029b79c1ed to your computer and use it in GitHub Desktop.
Save usayamadx/c76b6cd55bff968225cf1e029b79c1ed to your computer and use it in GitHub Desktop.
Response result, file download instead of console.log
let result = 'response json...' // api resonse ...etc
let domElement = document.createElement('a')
domElement.href = 'data:text/json,' + encodeURIComponent(JSON.stringify(result))
domElement.target = '_blank'
domElement.download = 'response.json'
domElement.click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment