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

【20161022】【ReactNative】【问题】IOS fetch Network request failed #37

Closed
zhongxia245 opened this issue Oct 22, 2016 · 0 comments

Comments

@zhongxia245
Copy link
Owner

一、RN 做 fetch 请求时,报以下错误

fetch(url, {method: 'GET', header: {'Content-Type': 'text/plain'}})
      .then(res=> res.json())
      .then(data=> {
        console.log("data", data)
        data = data || {}
        that.setState({articleList: data || []})
      })
      .catch(function (err) {
        console.log("err", err)
        that.setState({articleList: []})
      });
TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:28193:8)
    at XMLHttpRequest.dispatchEvent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:14591:15)
    at XMLHttpRequest.setReadyState (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29573:6)
    at XMLHttpRequest.__didCompleteResponse (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29431:6)
    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29506:52
    at RCTDeviceEventEmitter.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:13428:23)
    at MessageQueue.__callFunction (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11999:23)
    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11906:8
    at guard (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11857:1)
    at MessageQueue.callFunctionReturnFlushedQueue (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11905:1)

解决方案

参考地址

  1. http://stackoverflow.com/questions/38077273/react-native-fetch-network-request-failed-not-using-localhost
@zhongxia245 zhongxia245 changed the title 【ReactNative】【问题】IOS fetch 【ReactNative】【问题】IOS fetch Network request failed Oct 22, 2016
@zhongxia245 zhongxia245 changed the title 【ReactNative】【问题】IOS fetch Network request failed 【20161022】【ReactNative】【问题】IOS fetch Network request failed Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant