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 :
And when i send the api request with react-native i donāt get a log in my API console like this,
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:
- Created 5 years ago
- Reactions:1
- Comments:21
Top GitHub Comments
This definitely solved it for me.
added these to my
/android/app/src/main/AndroidManifest.xml
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)