Fix FormData

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-05-12 19:43:57 +02:00
parent 47b01ca078
commit ec918d497d
5 changed files with 16 additions and 9 deletions

View File

@ -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',

View File

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