I'm trying to send post request to url with an excel file that exists in a path but all the examples I tried tries to parse excel file. How can I send excel file as it is using the below code?
This is the method
static async postRequestForExcelUpload(url: string, query: object, token: string, file: object) {
try {
return await requestify.request(url, {
method: 'POST',
data: file,
query: query,
headers: {
Authorization: token,
"Content-Type": "multipart/form-data"
},
});
} catch (error) {
return error
}
}
and this is how I try to add my excel file
let path = "exceluploadfiles/excel.xlsx";
let data = new FormData();
await data.append("xlsx", await xlsx.readFile(path, {type: "file"}));
let responseEndpoint = await RestClient.postRequestForExcelUpload(
"/uploadexcel",
query,
token,
data
);