question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Network request Issues with react native 0.59

See original GitHub issue

šŸ› Bug Report

Hello, I recently encountered a problem with the network requests of my app. Before version 0.59 the requests to my API worked perfectly but since this version the requests to my API no longer work.

As you can see my api work perfectly : image

And when i send the api request with react-native i donā€™t get a log in my API console like this, image

To Reproduce

Make a network request with react-native 0.59 and you will get a network error Make a network request with react-native >0.59 and you will donā€™t get an error

Expected Behavior

You will get a network error in the console

Code Example

import qs from "qs";
import axios from "axios";
import { systemConstants } from "../constants";

interface credentials {
  email: string;
  password: string;
}

interface res {
  data: string;
}

const fetchUser = async (credentials: credentials) => {
  const requestOption = {
    method: "POST",
    headers: { "content-type": "application/x-www-form-urlencoded" },
    data: qs.stringify({
      email: credentials.email,
      password: credentials.password
    }),
    url: "http://192.168.1.25:3000/api/auth/login"
  };

  const res: res = await axios(requestOption);
  res.data;
};

export const userServices = {
  fetchUser
};

Environment

$ react-native info info React Native Environment Info: System: OS: Windows 10 CPU: (6) x64 IntelĀ® Coreā„¢ i5-8600K CPU @ 3.60GHz Memory: 8.95 GB / 15.95 GB Binaries: Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD

Thank you for your help !

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:21

github_iconTop GitHub Comments

77reactions
hammooooodycommented, Aug 6, 2019

This definitely solved it for me.

added these to my /android/app/src/main/AndroidManifest.xml

<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"  // <-- added this 
        ...>
        ...
    </application>
</manifest>
18reactions
darekg11commented, Mar 19, 2019

Your local API is served under HTTP, please add your API IP address to:
/android/app/src/debug/res/xml/react_native_config.xml
This is new since React Native 0.59 and recommended thing to do from Google (blocking all requests served under not crypted HTTP traffic)

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native fetch() Network Request Failed - Stack Overflow
When I create a brand new project using react-native init (RN version 0.29.1) andĀ ...
Read more >
react-native-video - npm
Start using react-native-video in your project by running `npm i ... Version 4.0.0 changes some behaviors and may require updates to yourĀ ...
Read more >
Networking - React Native
Take a look at the Fetch Request docs for a full list of properties. Handling the responseā€‹. The above examples show how you...
Read more >
Troubleshooting - React Navigation
The issues are not related to React Navigation, but due to the nature of how the Chrome Debugger works. When connected to Chrome...
Read more >
[typeerror: network request failed] - You.com | The AI Search ...
Edit: If you're using react-native-debugger, you would have to disable network inspect, otherwise the media files will not be able to upload. Open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found