change download file name
This commit is contained in:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user