0
_onPressButtonPOST(){
fetch("url", {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({"entryDate":"3/2/2017 2:00 AM","dia":"808","mobileType":"ANDROID","userName":"menutest"})})
.then((response) => response.json())
.then((responseData) => {
Alert.alert(
"Blood pressure data",
"Blood pressure data - " + JSON.stringify(responseData)
)
})
.done();
}
_onPressButtonGET(){
fetch("url", {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({"mobileType":"ANDROID","userName":"menutest"})})
.then((response) => response.json())
.then((responseData) => {
Alert.alert(
"Blood pressure data",
"Blood pressure data - " + JSON.stringify(responseData)
)
})
.done();
}
render(){
return(
<View>
<TouchableHighlight onPress={this._onPressButtonPOST} >
<Text>Add</Text>
</TouchableHighlight>
<TouchableHighlight onPress={this._onPressButtonGET} >
<Text>show</Text>
</TouchableHighlight>
</View>
);
}
我能值存储到数据库并获取他们回来,但我在警告对话框显示这些值,但我想在屏幕上显示,如何编辑我的代码来显示entryDate和dia在屏幕上,每当我点击显示按钮?在屏幕上显示的值,而不是在警告框
越来越像“错误未定义不是一个函数(评价“this2.setState({数据:responseData})) – Prasanna
变化'_onPressButtonGET(){''到_onPressButtonGET =() => {'。脂肪箭头功能自动绑定'this'。 – vinayr
这是不工作,通过点击显示什么也没有发生。 – Prasanna