Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda