react axios download zip file
export function someFunction(values) {
return (dispatch) => {
...
const method = 'GET';
const url = 'http://go.api/download_file';
...
axios
.request({
url,
method,
responseType: 'blob', //important
})
.then(({ data }) => {
const downloadUrl = window.URL.createObjectURL(new Blob([data]));
const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', 'file.zip'); //any other extension
document.body.appendChild(link);
link.click();
link.remove();
});
};
}
Also in JavaScript:
- javascript array map stack
- how to set json type jquery ajax
- javascript open in new window not tab
- jquery script url
- javascript reload page
- string methods javascript count number of words inside a string
- use strict javascript
- javascript remove quotes from string
- puppeteer set header
- angular model output only
- how to check string uppercase or lowersace using regex javascript
- express router middleware
- loop though json object in javascript
- import library react js
- js fill string with n characters
- moment js date between two dates
- tableau js
- electronjs ipc doesn't work
- jquery add style
- vuelidate require if
- javascript append list
- emotion.sh keyframes
- firebase update data
- react hide source code