You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.
@kdedakia, after the investigation, I've located a problem in our XMLHttpRequest implementation, when response header contains Content-Type : application/json, the xhr.response propertywill be converted to object (which simply JSON.parse xhr.responseText), this is based on my understanding to W3C standard.
However, the WHATWG-Fetch implementation and those ones in many browsers seems not convert xhr.response to JSON object when response header has the application/json content type, and this is why fetch does not working after replacing the XMLHttpRequest. The following code snippet is the body parser of WHATWG-Fetch
functionBody(){this.bodyUsed=falsethis._initBody=function(body){this._bodyInit=bodyif(typeofbody==='string'){this._bodyText=body}elseif(support.blob&&Blob.prototype.isPrototypeOf(body)){this._bodyBlob=body}elseif(support.formData&&FormData.prototype.isPrototypeOf(body)){this._bodyFormData=body}elseif(support.searchParams&&URLSearchParams.prototype.isPrototypeOf(body)){this._bodyText=body.toString()}elseif(!body){this._bodyText=''}elseif(support.arrayBuffer&&ArrayBuffer.prototype.isPrototypeOf(body)){// Only support ArrayBuffers for POST method.// Receiving ArrayBuffers happens via Blobs, instead.}else{thrownewError('unsupported BodyInit type')}
Since it does not ever expect xhr.response would be an object, it always throws error. I've change our implementation to fit the spec. You can try install the beta version and see if that works properly.
Derived #69
The text was updated successfully, but these errors were encountered: