对本地服务器反应本地Http请求-挂起,除非我在“远程调试JS”上(android)

时间:2018-10-22 13:27:56

标签: android react-native axios

我在使用axios向本地服务器执行任何http请求时遇到问题:

axios.post(url, data)

,对于 url 我尝试了:

url = "http://localhost:3000/authenticate"

url = "http://127.0.0.1:3000/authenticate"

url = "http://192.168.1.10:3000/authenticate" //服务器IP地址

url = "http://10.0.2.2:3000/authenticate" //仿真器地址

其中

None 都起作用...

有趣的是(我不明白为什么)是,只要“远程调试JS”,以下网址就可以正常工作: url = "http://10.0.2.2:3000/authenticate"

那么,我应该如何设置才能在不进行远程调试js的情况下实现这一目标?


在Android设备上尝试此操作。

"dependencies": {
    "axios": "^0.18.0",
    "babel-eslint": "^8.0.2",
    "country-data": "0.0.31",
    "hoist-non-react-statics": "^3.0.1",
    "libphonenumber-js": "^1.4.3",
    "native-base": "^2.7.2",
    "prop-types": "^15.6.0",
    "react": "16.3.1",
    "react-native": "~0.52.2",
    "react-native-animatable": "^1.2.4",
    "react-native-cli": "^2.0.1",
    "react-native-contacts": "^2.2.2",
    "react-native-easy-toast": "^1.1.0",
    "react-native-elements": "^0.19.1",
    "react-native-google-places-autocomplete": "^1.3.9",
    "react-native-keyboard-aware-scroll-view": "^0.4.1",
    "react-native-linear-gradient": "^2.3.0",
    "react-native-maps": "^0.21.0",
    "react-native-navigation": "^1.1.479",
    "react-native-scrollable-tab-view": "^0.8.0",
    "react-native-splash-screen": "^3.1.1",
    "react-native-tab-view": "^1.0.2",
    "react-native-toaster": "^1.2.2",
    "react-native-vector-icons": "^5.0.0",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.2.0",
    "tinycolor2": "^1.4.1"
  }

0 个答案:

没有答案