title: How to use the response in fetch request React Native
body: <p>I am new in react native world and (JS).
  I want to send <strong>phone number</strong> and <strong>password</strong> to the server to login. I can send data and receive response, however, I don't how I should handle response. I have a function called <strong>_response_recognizer</strong>. But it is not working. Even <strong>setStat</strong>. All of the tutorials only say how to connect to server and how fetch data from it. What is the best approach to use response in my login form. If it's status is 200 I want to navigate another screen, else I want to toast a message.</p>
  
  <pre><code>import React, {Component} from 'react';
  import {
      Platform,
      StyleSheet,
      Text,
      View,
      TextInput, Button
  } from 'react-native';
  
  export default class LoginForm extends Component&lt;{}&gt; {
      constructor(props) {
          super(props);
          this._onLogInPressed = this._onLogInPressed.bind(this);
          this._response_recognizer = this._response_recognizer.bind(this);
          this.state = {
              phone_number: '',
              password: '',
              data: {}
          };
      }
      _response_recognizer(data: string ){
  
      }
  
      _onLogInPressed = () =&gt; {
  
          var data = {
              'phone_number': this.state.phone_number,
              'password': this.state.password
          }
  
  
          fetch("http://192.168.1.12:5000/login", {
              method: "POST",
              headers: {
                      'Accept': 'application/json',
                      'Content-Type': 'application/json',
                  },
              body:  JSON.stringify(data)
          }).then(function(response){
                  return response.json();
              }).then(function(data){
                  console.log(data)
              this._response_recognizer(data)
              }) .catch((error) =&gt; {
              console.log("Error" + error);
          });
      };
  
      render() {
          return (
              &lt;View style={styles.flow}&gt;
                  &lt;Text style={styles.text}&gt;phone number:&lt;/Text&gt;
                  &lt;TextInput keyboardType='numeric'
                             style={styles.input}
                             ref="phone_number"
                             onChangeText={(phone_number) =&gt; this.setState({phone_number})}
                             maxLengt={11}
                             value={this.state.phone_number}
                  /&gt;
                  &lt;Text style={styles.text}&gt;password:&lt;/Text&gt;
                  &lt;TextInput style={styles.input} secureTextEntry={true} ref="password"
                             onChangeText={(password) =&gt; this.setState({password})}
                             value={this.state.password}/&gt;
                  &lt;Button style={styles.button} onPress={this._onLogInPressed} title='login'/&gt;
              &lt;/View&gt;
          );
      }
  }
  </code></pre>