React-Native post和get请求

post:

 fetchData (title) {
fetch(REQUEST_URL, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: un,
password: pw
})
})
.then((response) => response.json())
.then((responseData) => {
if (responseData['isOK']==='ok') {
ToastAndroid.show('登录成功', ToastAndroid.SHORT)
} else {
ToastAndroid.show('登录失败', ToastAndroid.SHORT)
}
})
.done()
}
   responseData (response) {
return response.result.data
}

get:

 fetchData: function () {
fetch(REQUEST_URL)
.then((response) => response.json())
.then((responseData) => {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(responseData),
loaded: true
})
})
.done()
},
上一篇:apache加载php配置


下一篇:.NetCore~Json代替了Xml