Fetch Request fails on android only
See original GitHub issueš Bug Report
I am not able to understand why my fetch request with multipart/formdata are failing for no
apparent reason, the error just shows fetch request failed
.
The strange part is the request completes on my backend like normal and my backend even send the response to the app till then the app has already failed to fetch.
Also, the same request completes the first time but failed after that. This works flawlessly on my ios devices.
Things Iāve already tried:
- Content-Type header is present
- Form data is correct (iāve tripple checked)
- request url is https
- form data image field has type property
Code Example
let body = await jsonToFormDataParser(...blah blah form data);
let { newCard: updatedCard, success } = await fetch(`${serverUrl}/api/create/card`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'multipart/form-data',
},
body
}).then(res => res.json());
Any help would be fantastic
Environment
React Native Environment Info: System: OS: macOS 10.14.3 CPU: (4) x64 Intel® Core⢠i5-5350U CPU @ 1.80GHz Memory: 183.94 MB / 8.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 11.10.0 - /usr/local/bin/node npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 23.0.1, 23.0.3, 25.0.1, 25.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.2, 28.0.3 System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs In tel x86 Atom IDEs: Android Studio: 3.3 AI-182.5107.16.33.5264788 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.3 => 0.59.3 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
@DodoTheDeveloper how does your comment solve this issue? https://github.com/facebook/react-native/issues/25244
@karanpratapsingh i had a similar problem and the fault was the SSL certificates (backend). If You cannot replace certificates on the server, you can use pinning (or ready packages, for example react-native-ssl-pinning or manual set to OkClient + TrustKit)