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.

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

See original GitHub issue

Environment

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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

4reactions
ravitejabhisetticommented, Nov 23, 2018

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

0reactions
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Axios get request hangs, no error, catch not fired
When I make a GET request with axios on node it just hangs, the catch is not thrown and error caught. Am not...
Read more >
Understanding Axios GET requests - LogRocket Blog
Learn how to make GET requests in Axios with query parameters and API keys, plus concurrent and HEAD requests and error handling.
Read more >
Errors | Node.js v19.3.0 Documentation
Node.js generates system errors when exceptions occur within its runtime environment. These usually occur when an application violates an operating system ...
Read more >
A Complete Guide to Winston Logging in Node.js - Better Stack
In this tutorial, we will explain how to install, set up, and use the Winston logger in a Node.js application. We'll go through...
Read more >
How to Debug Any CORS Error - HTTP Toolkit
Your request is hitting an error due to CORS. Not all is lost! Most CORS errors are quick & easy to debug and...
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