@ -1,3 +1,5 @@
|
||||
import { serialize } from 'object-to-formdata';
|
||||
|
||||
import { selectAccount } from 'soapbox/selectors';
|
||||
import { setSentryAccount } from 'soapbox/sentry';
|
||||
import KVStore from 'soapbox/storage/kv-store';
|
||||
@ -70,14 +72,11 @@ const patchMe = (params: Record<string, any>, isFormData = false) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch(patchMeRequest());
|
||||
|
||||
const headers: HeadersInit = isFormData ? {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
} : {};
|
||||
const headers: HeadersInit = isFormData ? { 'Content-Type': '' } : {};
|
||||
|
||||
let body: FormData | string;
|
||||
if (isFormData) {
|
||||
body = new FormData();
|
||||
Object.entries(params).forEach(([key, value]) => (body as FormData).append(key, value));
|
||||
body = serialize(params, { indices: true });
|
||||
} else {
|
||||
body = JSON.stringify(params);
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { serialize } from 'object-to-formdata';
|
||||
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useCreateEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks/useApi';
|
||||
@ -17,9 +19,7 @@ function useCreateGroup() {
|
||||
const api = useApi();
|
||||
|
||||
const { createEntity, ...rest } = useCreateEntity([Entities.GROUPS, 'search', ''], (params: CreateGroupParams) => {
|
||||
const formData = new FormData();
|
||||
|
||||
Object.entries(params).forEach(([key, value]) => formData.append(key, value));
|
||||
const formData = serialize(params, { indices: true });
|
||||
|
||||
return api('/api/v1/groups', {
|
||||
method: 'POST',
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { serialize } from 'object-to-formdata';
|
||||
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useCreateEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks/useApi';
|
||||
@ -16,7 +18,7 @@ function useUpdateGroup(groupId: string) {
|
||||
const api = useApi();
|
||||
|
||||
const { createEntity, ...rest } = useCreateEntity([Entities.GROUPS], (params: UpdateGroupParams) => {
|
||||
const formData = new FormData();
|
||||
const formData = serialize(params, { indices: true });
|
||||
|
||||
Object.entries(params).forEach(([key, value]) => formData.append(key, value));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user