【20161022】【ReactNative】【问题】IOS fetch Network request failed
Closed this issue · 0 comments
zhongxia245 commented
一、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)