-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch API fails to set Content-Type automatically #18
Comments
Do you use the latest version of this library? The latest version now is In fact, I have added this feature on 20 Jul, 2017. Refer to commit 2374527 /*
* Apply polifill to global object and append other prototype into it
*/
self.URLSearchParams = (nativeURLSearchParams && !isSupportObjectConstructor) ?
new Proxy(nativeURLSearchParams, {
construct: function(target, args) {
return new target((new URLSearchParamsPolyfill(args[0]).toString()));
}
}) :
URLSearchParamsPolyfill; As the code above, I added a You can try to update your library to the latest version and try again. If your problem not fixed, please add a comment to this issue and detail which browser and which version you tested. |
I just added the polyfill from NPM a few hours ago, double checked and it is definitely v2.0.1. The problem I described above is in the current version of Edge, so, 16 I think? I don't have the test system in front of me, I can double check Edge version if important. I'm not clear on how the commit you've linked to is supposed to address the problem I ran into with |
I checked on |
Yes, right, that's what I meant -- this shortcoming should be in the polyfill's documentation, and the workaround/fix would be cleaner if the polyfill exposed |
As what you said, it won't be feasible to patch the And I think... maybe it should expose a property (or anything else) to help checking whether the bowser supports |
I've added I discovered that there are so many browsers don't both support |
Thanks for the library! This comment should possibly be a separate ticket, but just to say in the README it says this in relation to this issue:
I think there is a typo in the first sentence and it's not clear exactly what it's trying to explain. Would be great if someone could clarify. Thanks! |
@iaincollins You can read the latest version of document here My English is not so good, and the document has corrected by @ryuhhnn in #23 |
I am using this polyfill, its working fine for Edge v40 but not on IE 11, |
Rahul, does that have anything to do with the Content-Type problem described in this issue? You might need to create a new issue to track your problem. (I noticed that the README does not list what versions of browsers are supported by the polyfill, or at least what versions have been tested -- might be nice to have!) |
I have some code along the lines of
I used this polyfill to get the URLSearchParams constructor working in Edge. This is fine, but in Chrome and Firefox, setting the POST body to a URLSearchParams instance also sets the
Content-Type
header toapplication/x-www-form-urlencoded
, per the Fetch spec. When using the polyfill, I have to manually set this header value in each Fetch call, usingheaders
in the options object.It would be great if the polyfill could hook/patch the
fetch
method to set this value automatically, but I suspect this won't be feasible. In that case, the documentation should be updated to note this additional usage requirement. Ideally, the library could expose a feature test function or a global variable that we could test against before manually setting headers:rather than always overriding the automatically-determined (in fully compliant browsers) content type.
The text was updated successfully, but these errors were encountered: