Skip to content
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

TypeError: Network request failed when using fetch in Android #31446

Closed
yim-jj opened this issue Apr 28, 2021 · 2 comments
Closed

TypeError: Network request failed when using fetch in Android #31446

yim-jj opened this issue Apr 28, 2021 · 2 comments
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.

Comments

@yim-jj
Copy link

yim-jj commented Apr 28, 2021

Description

  1. Fetch request fails only on Android, succeeds on iOS.
  2. Fails only on my team servers. Success on other servers. So, I changed https to http (my team server and client) and it succeeded.
  3. Same problem with axios.
  4. android:usesCleartextTraffic="true" => Also not helpful
  5. Flipper ...?? React Native 0.62.* [TypeError: Network request failed] on file upload #28551 => Also not helpful

React Native version:

System:
OS: macOS 11.3
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 731.05 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.10.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.7199119
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
Languages:
Java: 11.0.10 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.0 => 0.64.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

  1. set up project
    npx react-native init AwesomeTSProject --template react-native-template-typescript

  2. App.tsx
    async function helloServer() {
    try {
    const response = await fetch("https://www.*****.com/greeter/hello", {
    headers: new Headers({ "Content-Type": "application/json" }),
    });

    const json = await response.json();

    console.log(json);
    } catch (error) {
    console.log(error);
    }
    }

export default function App() {
useEffect(() => {
helloServer();
}, []);

return (

Open up App.tsx to start working on your app!

);
}

  1. npm run android (test with device)

Expected Results

Server response should be logged.

@yim-jj
Copy link
Author

yim-jj commented Apr 30, 2021

It was a SSL certificate issue. :(

@yim-jj yim-jj closed this as completed Apr 30, 2021
@ak2403
Copy link

ak2403 commented Jun 20, 2021

Same issue exists. The API call is working in a real device, but not in the emulator.

Now, my concern is, Should I worry that it doesn't work on emulator? It will be good if someone can answer this question, so that I can work with the real device until this issue is sorted out.

@facebook facebook locked as resolved and limited conversation to collaborators Apr 30, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants