Fix content-type for formdata
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -37,7 +37,7 @@ const uploadMediaV1 = (body: FormData, onUploadProgress = noOp) =>
|
||||
api(getState)('/api/v1/media', {
|
||||
method: 'POST',
|
||||
body,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
headers: { 'Content-Type': '' },
|
||||
// }, {
|
||||
// onUploadProgress: onUploadProgress,
|
||||
});
|
||||
@ -47,7 +47,7 @@ const uploadMediaV2 = (body: FormData, onUploadProgress = noOp) =>
|
||||
api(getState)('/api/v2/media', {
|
||||
method: 'POST',
|
||||
body,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
headers: { 'Content-Type': '' },
|
||||
// }, {
|
||||
// onUploadProgress: onUploadProgress,
|
||||
});
|
||||
|
||||
@ -23,9 +23,7 @@ function useCreateGroup() {
|
||||
|
||||
return api('/api/v1/groups', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
headers: { 'Content-Type': '' },
|
||||
body: formData,
|
||||
});
|
||||
}, { schema: groupSchema });
|
||||
|
||||
@ -22,9 +22,7 @@ function useUpdateGroup(groupId: string) {
|
||||
|
||||
return api(`/api/v1/groups/${groupId}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
headers: { 'Content-Type': '' },
|
||||
body: formData,
|
||||
});
|
||||
}, { schema: groupSchema });
|
||||
|
||||
@ -45,13 +45,16 @@ export const getFetch = (accessToken?: string | null, baseURL: string = '') =>
|
||||
const fullPath = buildFullPath(input.toString(), isURL(BuildConfig.BACKEND_URL) ? BuildConfig.BACKEND_URL : baseURL, init?.params);
|
||||
|
||||
const headers = new Headers(init?.headers);
|
||||
const contentType = headers.get('Content-Type') || 'application/json';
|
||||
|
||||
if (accessToken) {
|
||||
headers.set('Authorization', `Bearer ${accessToken}`);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', contentType);
|
||||
if (headers.get('Content-Type') === '') {
|
||||
headers.delete('Content-Type');
|
||||
} else {
|
||||
headers.set('Content-Type', headers.get('Content-Type') || 'application/json');
|
||||
}
|
||||
|
||||
return fetch(fullPath, {
|
||||
...init,
|
||||
|
||||
Reference in New Issue
Block a user