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
Response contructor is incompatible with other browser implementations #576
Comments
i get around it with the following code. const polyfilled = fetch.toString().includes('XMLHttpRequest');
if (polyfilled) {
const getClassOf = Function.prototype.call.bind(Object.prototype.toString);
const isClassOf = (instance, className) => getClassOf(instance).split(' ')[1].includes(className);
const PolyfilledResponse = window.Response;
window.Response = (first, second) => {
if (isClassOf(first, 'Object')) {
return new PolyfilledResponse(null, first);
}
return new PolyfilledResponse(first, second);
}
} |
Thanks for reporting! In the meantime, I think you can use |
so my original assumption that doing new Response(options) works on other browsers. it actually returns a response that is a 200, no matter if you did 204 or 400. so it will always be resp.ok |
Reopening to track updating our We need to handle the optional first https://github.com/github/fetch/blob/7a692dc519a3a110526a26c7e252f99991510c2a/fetch.js#L377-L380 |
The polyfill used to throw an exception, but the spec dictates that unsupported body types are simply converted to string. Closes #576
if you use new Response directly and use 204 responses you get the following issue.
new Response('', Init)
fails on chrome because it expects no body. you can do
new Response(null, init)
fails on Firefox because body cannot be null
but you can do in both firefox, chrome, Edge, safari
new Response(init);
but that fails when using this polyfill.
The text was updated successfully, but these errors were encountered: