I\'ve an API which returns an excel document as response. The request will be one simple json.
I\'ve searched google and found some code base to download the file and I
Set response-header { responseType: 'blob'}
in the request.
To download the excel, use the below function.
response - api response, fileName- excel name
downloadExcel(response, fileName) {
// Doing it this way allows you to name the file
var link = document.createElement('a');
link.href = window.URL.createObjectURL(res);
link.download = fileName;
link.click();
}