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
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