title: Get response from Laravel API in React Native
body: <p>I created an mobile application with React Native and i want use Laravel as backend. I created a register page to allow user register account through mobile application.</p>
  
  <p>When user press register button on mobile application. It will send request to laravel and return response.In my Register.js</p>
  
  <pre><code>async onRegisterPressed() {
      try{
          let response= await fetch('http://127.0.0.1:8000/api/register',{
              method: 'POST',
              headers: {
                  'Accept': 'application/json',
                  'Content-Type': 'application/json'
              },
              body: JSON.stringify({
                  user:{
                      name:this.state.name,
                      email:this.state.email,
                      password:this.state.password,
                      password_confirmation:this.state.password_confirmation,
                  }
              })
          });
  
          let res= await response.text();
          console.log("res is" + res);
      }catch(errors){
  
      }
  }
  </code></pre>
  
  <p>But in my Laravel Controller. I am not sure how to return the response of form validation.</p>
  
  <p>My Api\RegisterController</p>
  
  <pre><code>    public function register(Request $request){
          $this-&gt;validate($request,[
              'name' =&gt; 'required|max:255|unique:users',
              'email' =&gt; 'required|email|max:255|unique:users',
              'password' =&gt; 'required|min:8|confirmed',
              'gender'=&gt;'required|bool'
          ]);
  }
  </code></pre>
  
  <p>So how to get all errors and return it to react native? And should it be json format or Text format? Hope you guys can give me some hints because i just learn react native.</p>