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

Error [TypeError: Network request failed] #33960

Closed
anis-18 opened this issue Jun 4, 2022 · 6 comments
Closed

Error [TypeError: Network request failed] #33960

anis-18 opened this issue Jun 4, 2022 · 6 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@anis-18
Copy link

anis-18 commented Jun 4, 2022

Description

I'm having this error right now, everything worked fine, but i don't understand why i'm facing this error,
I've tried many solutions fot two days that's why i'm opening this issue
solutions that i've tried
changing url to my machine ip address
added paermission on AndroidManifest
added dns 8.8.8.8 to my network pereferences
created new simulator
tried on physical device

const handleSubmit = ({ question }) => {
    
     let headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
        };

   let data = JSON.stringify({
      question: question,
    });

    let options = {
      method: 'POST',
      headers: headers,
      data: data,
    };

    fetch('http://10.0.2.2:8081/answer/', options)
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.log('error', error));
  };

Version

0.68.2

Output of npx react-native info

System:
OS: macOS 12.4
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 993.57 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.0.0 - /usr/local/bin/node
Yarn: Not Found
npm: 8.6.0 - /usr/local/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 28, 29, 30, 31
Build Tools: 29.0.0, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2, 30.0.3, 31.0.0, 32.0.0
System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-31 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
Languages:
Java: 18.0.1 - /usr/local/opt/openjdk/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

expo init
i'm facing this error with a private project which was working but also when inilializing a new expo or react native projects

Snack, code example, screenshot, or link to a repository

Screenshot 2022-06-04 at 7 27 06 PM

@Rodrigo816
Copy link

Rodrigo816 commented Aug 22, 2022

Hey I'm having the same issue.
I also tried

     android:usesCleartextTraffic="true" 
     android:networkSecurityConfig="@xml/network_security_config"

and configured the XML and nothing works. This only started to happen when I upgraded my react native from 0.68 to 69.5. In ios all works fine.

@anis-18
Copy link
Author

anis-18 commented Feb 7, 2023

using react-native-debugger solved the issue for me.
but still having it without it

@hoatenhu
Copy link

fixed TypeError: Network request failed when upload file to http not https with Android debug builds

I have same issue. still need a solution

Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 17, 2024
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

4 participants