1.设一个request
let myRequest = new Request(urlPath,{
method:'POST',
headers:{
'Content-Type': 'application/x-www-form-urlencoded',
},
body:params,
});
2.进行fetch调用
fetch(myRequest)
.then((response) => {return response.json();})
.then((data) => {
this.state.dataList.push(data);
console.log(this.state.dataList[0]);
console.log(data);
})
.catch((error) => {
console.error(error);
Alert.alert("error!");
});
3.在React Native Debugger中看console.log输出