The issue is I want to download the response of the backend to the excel file and the response recognized as binary by talend API here is my code
function get_excels(type, id) {
$.ajax({
method: "GET",
url: URL+id+"/"+type+"/excel",
success: function (result) {
var blob = new Blob([result], {
type: "application/json",
});
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
console.log(link.href);
link.download = `excel.xlsx`;
link.click();
},
});
}
<i onclick="get_excels('transactions', 1)" class="fas fa-file-excel"></i>
When I download the file, Microsoft excel throws this error
I need to know how can I handle the response from the API and download It as an excel file. I will appreciate it If you can help me out.