-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
"Error: unsupported BodyInit type" returned for ALL fetch() requests #18818
Comments
Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run Thank you for your contributions. |
I also have the same issue. |
In android right? |
Having the same issue. Here's my react-native info: Stephens-MacBook-Pro:neighborplate smsenesac$ react-native info Environment: Packages: (wanted => installed) |
Here its something it might help: |
If I could hug you right now I would. Thanks! |
Has anyone fixed this without using any 3rd party lib? |
I am getting the same error when using chrome debugger. Removing We started experiencing this after upgrading from version 51 to 55. Is there a better way to inspect network requests? |
I overcame this issue by installing reactotron. It does grate on me having to install a heavy tool chain for something so fundamental though. |
Have the same issue. Is there any work on this issue? |
FYI: As of 2018-06-12 this is still a serious issue. No official response from React team 🙉🙈🙊. The only solution is to install either |
This was an issue for me and my coworker @sbleon when running the remote debugger while developing with iOS. In the remote debugger, I think that all of the polyfills supplied by React Native supersede the native implementations in Chrome. This is why we need to override the XMLHttpRequest polyfill with the native Chrome implementation to get network debugging working. As a result, we also need to override the RN polyfills with native Chrome implementations for objects used by the native XMLHttpRequest. My development environment is set up like so: if (typeof GLOBAL !== 'undefined') {
// Route network requests through Chrome's native XMLHttpRequest
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
// Use native Blob for native XMLHttpRequest set above
GLOBAL.Blob = GLOBAL.originalBlob || GLOBAL.Blob;
// Use native FileReader to read native Blob set above
GLOBAL.FileReader = GLOBAL.originalFileReader || GLOBAL.FileReader;
} Related: |
Per @shanecav84 's suggestion, I added in my [email protected] global.Blob = global.originalBlob ?
global.originalBlob :
global.Blob;
global.FileReader = global.originalFileReader ?
global.originalFileReader :
global.FileReader; works fine now with this hotfix. Full block: if (__DEV__) {
global.XMLHttpRequest = global.originalXMLHttpRequest ?
global.originalXMLHttpRequest :
global.XMLHttpRequest;
global.FormData = global.originalFormData ?
global.originalFormData :
global.FormData;
global.Blob = global.originalBlob ?
global.originalBlob :
global.Blob;
global.FileReader = global.originalFileReader ?
global.originalFileReader :
global.FileReader;
} |
@gabrielbull I'm not sure why, but it looks like [email protected] is not assigning the native edit |
Seems to be fixed in 0.56 |
Unless I'm misunderstanding, it looks like this issue is a bug with the When replacing react-native's |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Environment
Environment:
OS: Windows 10
Node: 9.9.0
Yarn: 1.5.1
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4670197
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.2 => 0.55.2
Steps to Reproduce
However if I
yarn add axios
and then try:Additionally, running the exact same
fetch
commands as posted above in a Chrome web browser on my Windows PC (the same one running the Metro Bundler) works fine.Expected Behavior
The request should resolve without any errors.
Actual Behavior
The request fails with:
It appears that the body of the fetch request is being generated as
Blob(4192) {size: 4192, type: "application/json"}
. However, this checkBlob.prototype.isPrototypeOf(body)
inside thefetch
library fails.I seems (eg. #6025) that this error occurs only for
POST
requests and only when failing to send the right headers. However, in my case I'm using a plainGET
request, with no body and even with all the right headers set -- I get the error.I have tried various different JSON APIs and try all return this error. I don't know what else to try.
I have also tried manually upgrading
whatwg-fetch
fromv1.1.1
(which is whatreact-native
installs) tov2.0.4
(which is the latest) and that returns the same error.Using the
axios
module (an alternative AJAX request lib) seems to work just fine. Requests are going through without any issues.I wonder if the "Long awaited Blob changes: upload, download, fetch locally, and more" introduced in
[email protected]
are the cause of this (given thatwhatwg-fetch
does constructor comparisons of globalBlob
objects).The text was updated successfully, but these errors were encountered: