Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. componentDidMount(){
  2.  
  3.  
  4.     const token = this.props.token;
  5.     const { navigation } = this.props;
  6.     const itemId = navigation.getParam('itemId', 'NO-ID');
  7.     const itemId2 = navigation.getParam('itemId2', 'NO-ID');
  8.     const otherParam = navigation.getParam('otherParam', 'some default value');
  9.     fetch('https://icartos.com/mobile/request?tk='+token+'&function=getAntecipationPeriod&dt_inicial='+itemId+'&dt_final='+itemId2)
  10.     .then((response) => response.json())
  11.       .then((responseJson) => {
  12.  
  13.  
  14.  
  15.             let state = this.state;
  16.             state.response = responseJson.response;
  17.             this.setState(state);
  18.  
  19.             if(responseJson.status == 1){
  20.  
  21.               {this.state.response = responseJson.response}
  22.               this.setState({loading: "0"});
  23.  
  24.             }else{
  25.               this.props.navigation.navigate('Login');
  26.             }
  27.  
  28.  
  29.            })
  30.           .catch((error) => {
  31.             {this.state.response = "[erro]"}
  32.             this.setState({loading: "0"});
  33.  
  34.       });
  35.  
  36.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement