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

App hangs on axios request to local server, but works when "Debug JS Remotely" #21899

Closed
ghost opened this issue Oct 22, 2018 · 5 comments
Closed
Labels
Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@ghost
Copy link

ghost commented Oct 22, 2018

Environment

React Native Environment Info:
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) 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));
  };
};
@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Oct 22, 2018
@Cytren
Copy link

Cytren commented Nov 22, 2018

I have the same issue on my project while using the 16.7.0-alpha.2 version of React. @fedecryto did you manage to solve the problem?

@ghost
Copy link
Author

ghost commented Nov 23, 2018

Hi @Cytren, I managed to solve it, but unfortunately was unintended. As soon as I cleared up a couple of warnings I had, the issue was magically gone. I couldn't find a way to reproduce the problem again.... and the warnings I cleared were independent of axios... so no clue what happened there. Probably one of those warnings was messing up other things... Sorry but I don't have a clear answer for you :s

@ravitejabhisetti
Copy link

I have the same issue.Can anyone suggest me how to resolve the issue.

@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Aug 9, 2019

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.

@stale stale bot closed this as completed Aug 9, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. 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