1fetch('https://cors-anywhere.herokuapp.com/' + fileURL, {
2 method: 'GET',
3 headers: {
4 'Content-Type': 'application/pdf',
5 },
6 })
7 .then((response) => response.blob())
8 .then((blob) => {
9 // Create blob link to download
10 const url = window.URL.createObjectURL(
11 new Blob([blob]),
12 );
13 const link = document.createElement('a');
14 link.href = url;
15 link.setAttribute(
16 'download',
17 `FileName.pdf`,
18 );
19
20 // Append to html link element page
21 document.body.appendChild(link);
22
23 // Start download
24 link.click();
25
26 // Clean up and remove the link
27 link.parentNode.removeChild(link);
28 });
29
1var fileDownload = require('js-file-download');
2fileDownload(data, 'filename.csv');
3