axios download excel \ 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();
});
};
}
axios({
url: 'http://api.dev/file-download',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf'); //or any other extension
document.body.appendChild(link);
link.click();
});
Also in JavaScript:
- javascript get body height
- if keypress javascript
- javascript read input from terminal
- duplicate encoder
- javascript get classlist of element
- javascript loop through class elements
- javascript format rupiah
- quill js server side delta
- docker node label add
- firebase realtime database increment value
- javascript array unique values
- variable used in a function can be used in another function js
- react array if id is present do not add element
- javascript return string
- boucle for in js
- delete first character javascript
- settimeout in vuejs
- check if a variable is array in javascript
- glitch node version
- fs.writefile
- angular download blob pdf
- Javascript track mouse pointer
- handleClick react
- mmap() failed: [12] Cannot allocate memory composer