Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
Download document using react(via API call) and show browser spinner instead of custom application spinner

I am trying to download documents uploaded in the application via fetchHandlers. While doing so I am making an API call and once API response(BLOB data) is available creating a object URL to download the document. Below is the code:

  downloadDocument(file.id, clientId)
    .then((res) => {
      const urlToDownload = URL.createObjectURL(res);
      const link = document.createElement("a");
      link.href = urlToDownload;
      link.setAttribute("download", `${file.name}`);

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

      // Start download
      link.click();

      // Clean up and remove the link
      link.parentNode.removeChild(link);
    })
    .catch((err) => {
      console.log(err);
    });
};

However, if the document size is big it takes a lot of time there is a need to show that the download is in progress. Google and Gmail handles this use case(download attachments) by showing the download in the bottom download bar and the spinner comes as part of the document icon. However using the above the download happens independently and the spinner in the taskbar appears only for a brief moment while the object url is clicked.

How can we use the inbuilt browser experience to show the spinner. This experience is visible in Google Chrome.

Please check the download bar below.

download bar

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!