I have done some EXCEL file export functions before, but they are all implemented using GET requests. The method I use is like this
// export excel module
handleExportTemplate:_debounce(function(){
window.location.href = process.env.BASE_API + `/export/excelDownload`
}),
I used the [window.location.href] method to let the browser download Excel automatically, but today the back-end engineer asked me to use a POST request and pass the parameters to him in the body. The data is similar to this:
data:{
userIdList:["1","2","3","4","5"],
ifShow:true,
ifDownLoadNow:true,
}
but using window.location.href, I don't know how to return these parameters to the backend engineer
In addition, I tried sending it to him using a normal POST request, and he did successfully return a file to me, but I couldn't get the browser to download it automatically through window.location.href
I tried to convince him to use GET request for this function, but he won't listen to me. Is it really appropriate to use POST for download requests? Is he wrong or I know too little? If it's my fault, how can I complete the POST request and be able to download EXCEL?