|
|
@@ -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)
|