i tried to download some file generated in my BE from API which work normal on other project but when i tried to use it in metronic excel can not read the file
my module:
@Action
[SalePlan.TEST]() {
return new Promise<void>((resolve, reject) => {
ApiService.post(`/bhtt/salePlan/test`, {}, { responseType: "blob" }).then(({ data }) => {
resolve(data);
})
.catch(({ response }) => {
reject(response);
});
});
}
this.store
.dispatch(SalePlan.TEST)
.then((res) => {
saveAs(
new Blob([res]),
"Report.xlsx"
);
});
Hi,
Thank you for reaching out to us.
Could you please specify which Metronic version you are using?
Do you have any errors in your browser's console?
Regards,
Lauris Stepanovs,
Keenthemes Support Team
im using Metronic 8 and there are no errors in console regarding fetching data from the API or downloading it using file-saver.
When i replace "ApiService" with "axios" it worked like normal
@Action
[SalePlan.TEST]() {
return new Promise<void>((resolve, reject) => {
axios.post(`/bhtt/salePlan/test`,{}, { responseType: "blob" }).then(({ data }) =>{
resolve(data);
})
.catch(({ response }) => {
reject(response);
});
});
}
After further inspections i've found that the ApiService.ts file on our project was changed when we were testing and getting used to the template, im sorry for taking your time and thank you for your reply
Hi,
Sorry for the late reply.
I am glad to hear you have already managed to fix it. Please let us know if you have more questions on this topic or anything else.
Regards,
Lauris Stepanovs,
Keenthemes Support Team