Created
January 8, 2020 10:24
-
-
Save shibinarakkan/fe181ebc54dd8bffc09d969880251b2a to your computer and use it in GitHub Desktop.
download file javascript
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
axios.post('link , { | |
token: "", | |
}, { | |
responseType: 'blob' | |
}).then(rsp => { | |
console.log(rsp); | |
let blob = new Blob([rsp.data]); | |
function download(filename, data) { | |
var element = document.createElement('a'); | |
element.href = URL.createObjectURL(blob); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
} | |
download("archive.zip", rsp.data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment