diff --git a/src/utils/request.js b/src/utils/request.js index 4113cc21b964e37ca51ffbdde6ea2093815ba19b..9b58189aa0a347cff4367da0059bf0e6a9094bf9 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -48,12 +48,21 @@ export default function request(url, options) { }; const newOptions = { ...defaultOptions, ...options }; if (newOptions.method === 'POST' || newOptions.method === 'PUT') { - newOptions.headers = { - Accept: 'application/json', - 'Content-Type': 'application/json; charset=utf-8', - ...newOptions.headers, - }; - newOptions.body = JSON.stringify(newOptions.body); + if (!(newOptions.body instanceof FormData)) { + newOptions.headers = { + Accept: 'application/json', + 'Content-Type': 'application/json; charset=utf-8', + ...newOptions.headers, + }; + newOptions.body = JSON.stringify(newOptions.body); + } else { + // newOptions.body is FormData + newOptions.headers = { + Accept: 'application/json', + 'Content-Type': 'multipart/form-data', + ...newOptions.headers, + }; + } } return fetch(url, newOptions)