From b7688bc6b0b21e7dd49f076e20ae6fb9a6022363 Mon Sep 17 00:00:00 2001 From: Andreas Fink Date: Thu, 20 Oct 2022 23:17:29 +0200 Subject: [PATCH] fix(rest): Fix empty Content-Type header (#2537) * fix(rest): Fix empty Content-Type header * Update runMethod.ts * Update runMethod.ts --- rest/runMethod.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rest/runMethod.ts b/rest/runMethod.ts index 3f9a0874e..99de072ea 100644 --- a/rest/runMethod.ts +++ b/rest/runMethod.ts @@ -46,12 +46,15 @@ export async function runMethod( ); } + const headers: HeadersInit = { + Authorization: rest.secretKey, + }; + if (body) { + headers["Content-Type"] = "application/json"; + } const result = await fetch(`${baseEndpoints.BASE_URL}${route}`, { body: body ? JSON.stringify(body) : undefined, - headers: { - Authorization: rest.secretKey, - "Content-Type": body ? "application/json" : undefined, - }, + headers, method, });