From 26a3eda983af24ca81df64dadb433f433d991b70 Mon Sep 17 00:00:00 2001 From: Ilya Semenov Date: Thu, 27 Apr 2023 11:48:22 +0700 Subject: [PATCH] fix: prevent crash on Chrome 49 --- src/fetch.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fetch.ts b/src/fetch.ts index cd9ebf5d..4487df9d 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -160,7 +160,8 @@ export function createFetch(globalOptions: CreateFetchOptions): $Fetch { // Set Content-Type and Accept headers to application/json by default // for JSON serializable request bodies. - context.options.headers = new Headers(context.options.headers); + // Pass empty object as older browsers don't support undefined. + context.options.headers = new Headers(context.options.headers || {}); if (!context.options.headers.has("content-type")) { context.options.headers.set("content-type", "application/json"); }