App hangs on axios request to local server, but works when "Debug JS Remotely"
See original GitHub issueEnvironment
React Native Environment Info: System: OS: macOS 10.14 CPU: x64 Intel® Core™ i5-7360U CPU @ 2.30GHz Memory: 30.03 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.12.0 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.0, macOS 10.14, tvOS12.0, watchOS 5.0 IDEs: Android Studio: 3.2 AI-181.5540.7.32.5014246 Xcode: 10.0/10A255 - /usr/bin/xcodebuild npmPackages: react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 react-native: 0.57.3 => 0.57.3 npmGlobalPackages: react-native-cli: 2.0.1
Description
Hi!
I’m having problems to perform any http request using axios to a local server:
axios.post(url, data)
and for url I tried: url = “http://localhost:3000/authenticate” url = “http://127.0.0.1:3000/authenticate” url = “http://192.168.1.10:3000/authenticate” //server ip address url = “http://10.0.2.2:3000/authenticate” //emulator address
and NONE of them worked…
The funny thing (and I can’t understand why) is that as soon as “Debug JS Remotely” the following url worked perfectly: url = “http://10.0.2.2:3000/authenticate”
So, how should it be my set up to make this work without debugging js remotely??
Reproducible Demo
export const loginUser = userData => {
return dispatch => {
axios
.post(`${url}/authenticate`, userData)
.then(res => {
if (res.data.success) {
dispatch(setUser(res.data.user));
} else {
//Auth error
dispatch({
type: SET_ERROR,
payload: res.msg
});
}
})
.catch(err => console.log(err));
};
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5
Top GitHub Comments
I have the same issue.Can anyone suggest me how to resolve the issue.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.