1axios({
2 url: 'http://api.dev/file-download', //your url
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});
13