From 3cab766bb35a9cb01e3bb77f595bd3cf7e5be170 Mon Sep 17 00:00:00 2001 From: Christian Stoyanov Date: Mon, 11 May 2020 22:48:42 +0200 Subject: [PATCH 1/2] Added withCredentials option. Don't know how to test this --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index f4c86f2..16bc779 100644 --- a/src/index.js +++ b/src/index.js @@ -142,7 +142,7 @@ export default (function create(defaults) { } } } - + const fetchFunc = options.fetch || fetch; const customHeaders = {}; @@ -172,7 +172,8 @@ export default (function create(defaults) { return fetchFunc(url, { method: options.method, body: data, - headers: deepMerge(options.headers, customHeaders, true) + headers: deepMerge(options.headers, customHeaders, true), + credentials: options.withCredentials === true ? 'include' : 'same-origin' }).then((res) => { let i; for (i in res) { From f19f9a53e1e9128c99da775b60aaa91893726c29 Mon Sep 17 00:00:00 2001 From: Christian Stoyanov Date: Fri, 12 Jun 2020 12:13:47 +0200 Subject: [PATCH 2/2] Optimize character count --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 16bc779..792f758 100644 --- a/src/index.js +++ b/src/index.js @@ -173,7 +173,7 @@ export default (function create(defaults) { method: options.method, body: data, headers: deepMerge(options.headers, customHeaders, true), - credentials: options.withCredentials === true ? 'include' : 'same-origin' + credentials: options.withCredentials && 'include' }).then((res) => { let i; for (i in res) {