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

255
Views
Error download with blob, laravel and react

I'm trying to do an automatic file download but this don't work like that, instead of downloading redirect. Is like the attribute download of label don't work

redirect page

My code:

axios.post(`${Global.url}report/general/receipt-list/report`, report, headers)
    .then((res) => {
        console.log(res.data);
      const url = window.URL.createObjectURL(new Blob([res.data]));
      console.log(res.data);
      const link = document.createElement('a');
      link.href = url;

      if(report.type === 'xlsx') {
          console.log('ee1')
          link.setAttribute('download', `REPORTE_CAJA_(${format(report.since, 'dd-MM-yyyy')}_${format(report.to, 'dd-MM-yyyy')}).xlsx`); //or any other extension
      } else{
          link.setAttribute('download', `REPORTE_CAJA_(${format(report.since, 'dd-MM-yyyy')}_${format(report.to, 'dd-MM-yyyy')}).pdf`); //or any other extension
      }

      console.log('')
      document.body.appendChild(link);
     // console.log('ee')
      link.click();
      showPreloader(false);

    })
    .catch((err) => {
      console.log(err);
    });

Sorry for my bad English, i don't speak it but I'm trying so hard to make this work, a few days ago this code was working

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!