change download file name

This commit is contained in:
Mohamed Nouffer
2021-11-16 10:46:45 +05:30
parent 24a0a6e975
commit 86f86195eb
9 changed files with 47 additions and 29 deletions

View File

@ -115,30 +115,48 @@ function Index() {
}
function downloadReport(url) {
axios({
url: url, //your url
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
// const url = window.URL.createObjectURL(new Blob([response.data]));
// const link = document.createElement('a');
// link.href = url;
// //link.setAttribute('download', 'file.xls'); //or any other extension
// //document.body.appendChild(link);
// link.click();
const filename = response.headers
fetch("url of api")
.then(async response => {
const filename = response.headers
.get("content-disposition")
.split('"')[1];
const text = response.text();
const text = await response.text();
console.log(filename)
console.log(text)
//return { filename, text };
});
})
.then(responseText => this.download(responseText))
.catch(error => {
//messageNotification("error", error.message);
throw new Error(error.message);
});
}
// function downloadReport(url) {
// axios({
// url: url, //your url
// method: 'GET',
// responseType: 'blob', // important
// }).then((response) => {
// // const url = window.URL.createObjectURL(new Blob([response.data]));
// // const link = document.createElement('a');
// // link.href = url;
// // //link.setAttribute('download', 'file.xls'); //or any other extension
// // //document.body.appendChild(link);
// // link.click();
// const filename = response.headers
// .get("content-disposition")
// .split('"')[1];
// const text = response.text();
// console.log(filename)
// console.log(text)
// //return { filename, text };
// });
// }
const checkAvilable = (date) => {
if(validDates === undefined){
return false;