title: How to show alert message when invalid login credentials in React Native?
body: <p>I want to show an alert message when user login fails.But alert is not showing.Following is my code in react native.</p>
  
  <p><strong>login</strong></p>
  
  <pre><code>   onPressLogin(){
      fetch('http://192.168.1.10:3000/users/login',{
          method: 'POST',
          headers:{
                  'Content-Type' : 'application/json',
          'Accept':'application/json'
              },
              body: JSON.stringify({
                  contact:this.state.contact,
                  password: this.state.password,
              })
  })
    .then(response =&gt; response.json())
    .then((responseData) =&gt;
          {
      this.setState({
          userdetail: responseData,
          })
  if(responseData){
    setTimeout(() =&gt; {
      Actions.firstScreen();
    }, 2300);
    AsyncStorage.saveItem('userid', this.state.userData.phone_no);
  
  } else {
    console.log(responseData);
    Alert(responseData);
  }
  }); 
  
  }
  </code></pre>
  
  <p>What I'm getting now is it will redirect to <code>firstScreen</code> on successful login but it alert is not coming on unsuccessful login.When I consoled I'm getting unexpected end of json input error but I'm using node js as backend the error result is showing there following is my code in nodejs </p>
  
  <pre><code>else {
                   appData.error= 1;
                   appData["data"] = "Phone number and Password does not match";
                   res.status(204).json(appData);
                   console.log(appData);
                 }
               }else{
                 appData.error=1;
                 appData["data"] ="Phone number does not exist";
                 res.status(204).json(appData);
                 console.log(appData);
               }
  </code></pre>
  
  <p>the consoled result of <code>appData</code> is </p>
  
  <pre><code>{ error: 1, data: 'Phone number does not exist' }
  </code></pre>
  
  <p>I don't know the reason why this error message is not showing within <code>responseData</code> in react native.</p>