(function (iNum, uniqueUrl) {
fetch(uniqueUrl, {
method: "POST",
headers: {
// 'Content-Type': 'application/json',
},
body: JSON.stringify({}),
})
.then(function (response) {
return response.blob();
})
.then(function (blob) {
if (blob.type == 'text/csv') {
message
.create({
title: "REPORT EXPORT",
message: "File size is greater than 10MB, and it is downloaded as a CSV file",
type: message.Type.CONFIRMATION,
})
.show({
duration: 15000, // will disappear after 15s
});
let url = window.URL.createObjectURL(blob);
let a = document.createElement("a");
console.log("blob element", a)
a.href = url;
a.download =
'Item Pricing Report - ' + iNum + "-" + Date.now() / 1000 + ".csv";
document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox
a.click();
a.remove(); //afterwards we remove the element again
}
if (blob.type == 'application/vnd.ms-excel') {
let url = window.URL.createObjectURL(blob);
let a = document.createElement("a");
console.log("blob element", a)
a.href = url;
a.download =
'Item Pricing Report - ' + iNum + "-" + Date.now() / 1000 + ".xls";
document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox
a.click();
a.remove(); //afterwards we remove the element again
}
});