Answers for "react js download file"

3

react js download file

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);
  });
Posted by: Guest on December-29-2020
0

download file in react

var fileDownload = require('js-file-download');
fileDownload(data, 'filename.csv');
Posted by: Guest on May-09-2021
-2

react.js download

npm install --save react-download-link
Posted by: Guest on December-09-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language