response excel file in axios
See original GitHub issueI have a api that return an excel file from backend, this is my code
` ‘downloadErrorDetailBlast’: function () {
let url = '/api/' + auth2.currentUser.get().getBasicProfile().getEmail() + '/blasts/' + this.blastEmailId + '/files'
let options = {
headers: {
'Authorization': 'Bearer ' + this.$session.get('user').idToken,
'responseType': 'application/vnd.ms-excel'
}
}
axios.get(url, options)
.then(this.downloadErrorDetailBlastSuccess)
.catch(this.downloadErrorDetailBlastFailure)
},
'downloadErrorDetailBlastSuccess': function (response) {
const url = window.URL.createObjectURL(new Blob([response.data], {type:'application/vnd.ms-excel'}));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'Detail_Blast.xls');
document.body.appendChild(link);
link.click();
console.log(response.data)
alert("File Berhasil Didownload!")
},`
But, when I console.log my response.data, the data seems weird like this
I wanna download my respose.data as an excel file. What should I do?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Axios Excel file download using POST results in corrupted file
I have been able to download the file using Postman so I know the file served by the endpoint is fine. I just...
Read more >axios download excel file - Code Examples & Solutions For ...
axios download excel \ file ; 1. axios({ ; 2. url: 'http://api.dev/file-download', ; 3. method: 'GET', ; 4. responseType: 'blob', // important ;...
Read more >Download a File with Vue and Axios - Larry Kagan
Once that's set, we'll create a method in the component to send the request via Axios and tell the browser to download (not...
Read more >React Export Data To Excel Using Axios For Api Calls - YouTube
React Export Data To Excel Using Axios For Api Calls || Custom ExcelSheet Cell Formatting With Color.Download:// required framework an ...
Read more >How to download excel in response from api react js - Edureka
But when I try to post some data using POST request in axios response I am getting this how to handle. API response...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
try change options from
to
你可以用fetch