From 008c53ae28a2f08049fe3b0080b063a09d4cd504 Mon Sep 17 00:00:00 2001 From: tjg1 <1909894+tjg1@users.noreply.github.com> Date: Thu, 26 Nov 2020 18:29:33 +0100 Subject: [PATCH] Set default Content-Type for request bodies --- src/lib/fetch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 8619cccb..b9edaaab 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -38,7 +38,7 @@ export async function post(url: string, body: object, options?: FetchOptions): P return new Promise((resolve, reject) => { fetch(url, { method: 'POST', - headers: options?.headers || {}, + headers: { 'Content-Type': 'text/plain;charset=UTF-8', ...options?.headers }, body: JSON.stringify(body), }) .then((result) => { @@ -54,7 +54,7 @@ export async function put(url: string, body: object, options?: FetchOptions): Pr return new Promise((resolve, reject) => { fetch(url, { method: 'PUT', - headers: options?.headers || {}, + headers: { 'Content-Type': 'text/plain;charset=UTF-8', ...options?.headers }, body: JSON.stringify(body), }) .then((result) => {