From a0bfb6cb2478cf3918c9aaa44f8129f65149fee1 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Wed, 21 Dec 2022 15:21:35 +0100 Subject: [PATCH] Another fix #597 --- src/api/general.ts | 5 ++++- src/api/tooot.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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({