网络请求失败,反应原生,ios,ios app expo

时间:2017-11-02 07:10:36

标签: react-native react-native-ios

我使用react native来发送GET请求,但反应原生返回网络
请求失败。
我不知道要解决它。
我使用fetch发送请求,我可以在我的浏览器中获取资源https://localhost:3011/hellohttps://my ip number:3011 / hello。

但是在我的提取中我无法获得请求 我的代码是

totals.visits=1

我最后得到this.state.content是'123'。所以有一个错误。 而且我搜索了很多页面以获取信息无法帮助。 我将export default class App extends React.Component { constructor(props) { super(props); this.state = { content: '666', }; } componentDidMount() { return fetch('https://localhost:3011/hello') .then(response => (response)=> response.json()) .then((responseJson) => { this.setState({content: '789'}); }) .catch((error) => { this.setState({content: '123'}); console.log(error) }); } render() { return ( <View style={styles.container}> <Text style={styles.item}>{this.state.content}</Text> <Text style={styles.item}>999</Text> </View> ); } } 更改为localhostmy ip10.0.2.2也无法帮助。 我在世博会上运行我的应用程序。

0 个答案:

没有答案