Here is body request
Here is my code
fetch(`${proxy()}${dataUrlExport}`, {
method: "POST",
headers: {
"content-type": "application/json",
Accept:
exportType === "excel"
? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
: "text/csv",
},
body: JSON.stringify(exportBody),
})
.then((res) => res.blob())
.then((blob) => {
if (exportType === "csv") {
const bom = new Uint8Array([0xef, 0xbb, 0xbf]);
const withBom = new Blob([bom, blob], { type: "text/csv" });
blob = withBom;
}
const url = window.URL.createObjectURL(blob);
////////console.log(1300, url)
const a = document.createElement("a");
a.style.display = "none";
a.href = url;
const datetimeString = getCurrentDateTimeForFilename();
const segments = page.page_title.split("/");
const lastSegment = segments[segments.length - 1]; //tĂȘn
const result = lastSegment.replace(/-/g, "");
a.download =
exportType === "excel"
? `DATA_${result.toUpperCase()}_${exportBody.criteria}_${datetimeString}.xlsx`
: `DATA_${result.toUpperCase()}_${datetimeString}.csv`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
setLoadingExportFile(false);
setSelectedFields([]);
setSelectAll(false);
I want it to be included when I download the file name is exportBody.criteria: RF20243220001 but I get object
How do I get it and assign it to the filename?
tks guys