Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

downlaod file from website raect

fetch('https://cors-anywhere.herokuapp.com/' + fileURL, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/pdf',
    },
  })
  .then((response) => response.blob())
  .then((blob) => {
    // Create blob link to download
    const url = window.URL.createObjectURL(
      new Blob([blob]),
    );
    const link = document.createElement('a');
    link.href = url;
    link.setAttribute(
      'download',
      `FileName.pdf`,
    );

    // Append to html link element page
    document.body.appendChild(link);

    // Start download
    link.click();

    // Clean up and remove the link
    link.parentNode.removeChild(link);
  });
Comment

PREVIOUS NEXT
Code Example
Javascript :: check version of 3rd package npm 
Javascript :: implict type coercion in js 
Javascript :: javascript react store component as function 
Javascript :: Previously visited page with vanilla JavaScript 
Javascript :: custu, loading next js 
Javascript :: Make an array from the HTML Collection to make it iterable 
Javascript :: loadash 
Javascript :: what is the equivalent of cascade on delete in mongoose 
Javascript :: request body goes undefined in nodejs mongodb 
Javascript :: math library javascript 
Javascript :: applicature 
Javascript :: Private slots are new and can be created via Private methods and accessors 
Javascript :: useHistory: useNavigate if you install v6 or more than react-router-dom": ^6.2.1 
Javascript :: Uncaught TypeError: document.getElementsByClassName(...).style is undefined 
Javascript :: filter state based on text field react 
Javascript :: How To Start Any Program In Background Using Vbscript 
Javascript :: python range equivalent in javascript 
Javascript :: eslint failed to load react 
Javascript :: Example of Nullish coalescing assignment operator in es12 
Javascript :: show route between markers google maps javascript 
Javascript :: json_populate_recordset 
Javascript :: merge json data in main.go in golang 
Javascript :: close worker 
Javascript :: axios xmlhttpReq 
Javascript :: salman javascript id 
Javascript :: use this in a react js component 
Javascript :: split a table by sertain number of entities javascript 
Javascript :: provider not found react 
Javascript :: how to make a popeyes chicken sandwich 
Javascript :: jquery validate required false with additional function 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =