From 5c24342a54f06dc15f557bc03d44b49225270e77 Mon Sep 17 00:00:00 2001 From: Ilya Semenov Date: Wed, 7 Jun 2023 01:51:35 +0700 Subject: [PATCH] fix: pass empty object to headers initializer to prevent crash on chrome 49 (#235) --- src/fetch.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fetch.ts b/src/fetch.ts index cd9ebf5..4487df9 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"); }