react-native TypeError:网络请求失败

时间:2016-06-06 20:59:21

标签: ios iphone reactjs react-native

尝试通过#fetch()验证应用程序 - 抛出TypeError:...

尝试在appdelegate.m中添加我的本地ip add,  但没有工作

请帮忙 - 这是我的代码

var test2 = React.createClass({
    _onPressButtonPOST: function() {
        fetch('https://test.xxx.com/authenticate/', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            username : 'uname',
           password : 'pw123',
           fingerprint : '12637pw',
          })
        })

            .then((response) => response.text())
            .then((responseText) => {
              console.log(responseText);
            })
            .catch((error) => {
              console.warn(error);
            });

    },  
    render() {
    return (
      <View style={styles.main}>
      <Image source={require('./bg.png')} style={styles.backgroundImage}>
              <ScrollView> 
                    <View style={styles.container}>
                        <TouchableHighlight onPress={this._onPressButtonPOST} style={styles.button}>
                            <Text>POST</Text>
                        </TouchableHighlight>
                    </View>
              </ScrollView> 

    </Image>
    </View>
    );
  }
});

0 个答案:

没有答案
相关问题