diff --git a/src/api/general.ts b/src/api/general.ts index 79340041..d8433546 100644 --- a/src/api/general.ts +++ b/src/api/general.ts @@ -44,7 +44,10 @@ const apiGeneral = async ({ ...userAgent, ...headers }, - ...((body as (FormData & { _parts: [][] }) | undefined)?._parts.length && { data: body }) + ...(body && + (body instanceof FormData + ? (body as (FormData & { _parts: [][] }) | undefined)?._parts?.length + : Object.keys(body).length) && { data: body }) }) .then(response => { let links: { diff --git a/src/api/tooot.ts b/src/api/tooot.ts index 3b2a8fa5..c491438a 100644 --- a/src/api/tooot.ts +++ b/src/api/tooot.ts @@ -47,7 +47,10 @@ const apiTooot = async ({ ...userAgent, ...headers }, - ...((body as (FormData & { _parts: [][] }) | undefined)?._parts.length && { data: body }) + ...(body && + (body instanceof FormData + ? (body as (FormData & { _parts: [][] }) | undefined)?._parts?.length + : Object.keys(body).length) && { data: body }) }) .then(response => { return Promise.resolve({