react native AsyncStorage
componentDidMount() {
let _that=this;
AsyncStorage.getItem('userid',(err, result) => {
console.log(result);
var userid=result;
var startday=this.state.startday;//set date
var endday=this.state.endday;//set date
console.log(userid);
console.log(startday); //check date
console.log(endday);
var url = 'http://47.90.60.206:8080/pt_server/sportchart.action'; // create url
// var url = 'http://192.168.20.12:8080/pt_server/traineelogin.action';
url += '?userid='+userid+'&start='+startday+'&end='+endday;
console.log(url); //check url
fetch(url).then(function(response) {
return response.json();
}).then(function(res) {
console.log(res);//check json,then render the view again
if (res["data"]!=null) {
_that.setState(
{
}
);
}else{
Alert.alert('error'); //alert warning and error
}
});
});
}