Skip to content

Commit

Permalink
Fix for an error using URLSearchParams with fetch
Browse files Browse the repository at this point in the history
Fix the following error occurred in WeChat Windows client (based on Chrome 53 from UA), when passing an `URLSearchParams` as body not not passing headers.

message: "Failed to construct 'Headers': No matching constructor signature."
stack: TypeError: Failed to construct 'Headers': No matching constructor signature.
 at TypeError (native)
 at fetch (webpack-internal:///./node_modules/core-js/modules/web.url-search-params.js:328:23)
 at _callee$ (webpack-internal:///./src/api/internal.ts:180:20)
 at tryCatch (webpack-internal:///./node_modules/regenerator-runtime/runtime.js:45:40)
...
  • Loading branch information
huww98 authored Oct 29, 2019
1 parent e3f4c9e commit 763b979
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core-js/modules/web.url-search-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ if (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'functio
if (isObject(init)) {
body = init.body;
if (classof(body) === URL_SEARCH_PARAMS) {
headers = new Headers(init.headers);
headers = init.headers ? new Headers(init.headers) : new Headers();
if (!headers.has('content-type')) {
headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
}
Expand Down

0 comments on commit 763b979

Please sign in to comment.