title: How to solve 422 error in Lumen react Post request?
body: <p>I am new in Lumen also in React, so i don't know what is going wrong with my code it return the error like below, I am using axios library. <strong>It works fine in postman</strong></p>
  
  <p><a href="https://i.stack.imgur.com/vMNjG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vMNjG.png" alt="enter image description here"></a></p>
  
  <p><strong>Here is my react code</strong></p>
  
  <pre><code>handleFormSubmit = (event) =&gt; {
          event.preventDefault();
          const data = {
              name: this.state.name,
              email: this.state.email,
              password: this.state.password
          }
  
          // Axios.post('http://localhost:8000/api/register', data).then(res =&gt; {
          //     console.log(res);
          // })
  
          fetch('http://localhost:8000/api/register', {
              method: 'POST',
              body: data
          }).then(res =&gt; {
              console.log(res);
          });
      }
  </code></pre>
  
  <p><strong>Lumen Code</strong></p>
  
  <pre><code>    public function register(Request $request)
      {
          $rules = [
              'email' =&gt; 'required|email|unique:users',
              'name' =&gt; 'required|min:5',
              'password' =&gt; 'required|min:6'
          ];
  
          $this-&gt;validate($request, $rules);
  
          $name = $request-&gt;input('name');
          $email = $request-&gt;input('email');
          $password = $request-&gt;input('password');
  
          $hashPassword = Hash::make($password);
  
          $user = User::create([
              'email' =&gt; $email,
              'name' =&gt; $name,
              'password' =&gt; $hashPassword
          ]);
  
          return response()-&gt;json(['status' =&gt; 'success', 'user_id' =&gt; $user-&gt;id], 201);
      }
  
  </code></pre>
  
  <p>Any solution appreciated!</p>