Skip to content

Commit

Permalink
🐛 Fix fileDownload request using formData for post request method
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Dec 27, 2024
1 parent c0498e3 commit 3cf58cf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/utils/XHR.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,14 @@ export const XHR = {
timeout = setTimeout(() => {
reject('Timeout');
}, TIMEOUT);

downloadFile({
url: 'GET' === httpMethod ? `${url}${data ? '?' + new URLSearchParams(JSON.parse(JSON.stringify(data || {}))).toString() : ''}` : url,
headers: {
'Content-Type': 'application/json',
'Access-Control-Expose-Headers': 'Content-Disposition', //need to get filename from server
},
method: httpMethod,
data: data && JSON.stringify(data),
//set form data to download file @since 3.11.0 to replace $.fileDownload from 3.10.x
data: 'POST' === httpMethod ? Object.keys(data || {}).reduce((a, k) => { a.append(k, data[k]); return a; }, new FormData()): undefined,
signal,
})
return resolve();
Expand Down

0 comments on commit 3cf58cf

Please sign in to comment.