axios download excel 5c file

Solutions on MaxInterview for axios download excel 5c file by the best coders in the world

showing results for - "axios download excel 5c file"
Lilou
29 Sep 2018
1axios({
2  url: 'http://api.dev/file-download',
3  method: 'GET',
4  responseType: 'blob', // important
5}).then((response) => {
6   const url = window.URL.createObjectURL(new Blob([response.data]));
7   const link = document.createElement('a');
8   link.href = url;
9   link.setAttribute('download', 'file.pdf'); //or any other extension
10   document.body.appendChild(link);
11   link.click();
12});
Bruce
23 Oct 2016
1
2export function someFunction(values) {
3
4  return (dispatch) => {
5
6    ...
7
8    const method = 'GET';
9
10    const url = 'http://go.api/download_file';
11
12    ...
13
14    axios
15
16      .request({
17
18        url,
19
20        method,
21
22        responseType: 'blob', //important
23
24      })
25
26      .then(({ data }) => {
27
28        const downloadUrl = window.URL.createObjectURL(new Blob([data]));
29
30        const link = document.createElement('a');
31
32        link.href = downloadUrl;
33
34        link.setAttribute('download', 'file.zip'); //any other extension
35
36        document.body.appendChild(link);
37
38        link.click();
39
40        link.remove();
41
42      });
43
44  };
45
46}
47
48