Skip to content

Instantly share code, notes, and snippets.

@shibinarakkan
Created January 8, 2020 10:24
Show Gist options
  • Save shibinarakkan/fe181ebc54dd8bffc09d969880251b2a to your computer and use it in GitHub Desktop.
Save shibinarakkan/fe181ebc54dd8bffc09d969880251b2a to your computer and use it in GitHub Desktop.
download file javascript
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