title: REACT call (Post) to Api (Laravel) return error 500
body: <p>I am fairly new to web developing and i am currently practicing with laravel and react.</p>
  <p>At the moment i have a problem with a api call (post) getting back an error 500.</p>
  <p>Here is the php code:</p>
  <p>Model</p>
  <pre><code>protected $fillable = [
      'id',
      'name',
      'address',
      'phone',
      'email'
  </code></pre>
  <p>Controller</p>
  <pre><code>public function store(Request $request)
  {
      $customer = Customer::create($request-&gt;all());
      return response()-&gt;json($customer, 201);
  }
  </code></pre>
  <p>Api route</p>
  <pre><code>Route::apiResource('customers', 'App\Http\Controllers\CustomerController');
  </code></pre>
  <p>Here is the js code:</p>
  <p>service (customers.js)</p>
  <pre><code>  export async function addCustomer(customer) 
    {
      fetch( '/api/customers/', 
      {
        method:'post',
        headers: 
        {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(customer)
      })
      .then(response =&gt; 
      {
        console.log(response);
        return response.json();
      })
    }
  </code></pre>
  <p>component (CustomerForm.js)</p>
  <pre><code>const CustomerForm = ({customer, showForm}) =&gt; {
      [...]
      const handleSubmit = (e) =&gt; 
          {
          e.preventDefault(); 
          addCustomer(model)
          .then(i =&gt; {}, 
              error =&gt; 
                {
                console.log(error.message)
                })
          .catch(e =&gt; 
            {
            console.log(e)
            console.log(response)
            }); 
           }
  
      /**
       * render
       */
      return (
          [...]
      );
  }
  
  export default CustomerForm;
  </code></pre>
  <p>Here is the error:</p>
  <pre><code>POST http://127.0.0.1:8000/api/customers/ 500 (Internal Server Error)
  _callee3$   @   app.js:6606
  tryCatch    @   app.js:6524
  (anonymous) @   app.js:6524
  (anonymous) @   app.js:6524
  asyncGeneratorStep  @   app.js:6526
  _next   @   app.js:6528
  (anonymous) @   app.js:6528
  (anonymous) @   app.js:6528
  _addCustomer    @   app.js:6625
  addCustomer @   app.js:6594
  handleSubmit    @   app.js:5704
  onSubmit    @   app.js:5725
  [...]
  </code></pre>
  <p>What I've done:</p>
  <ul>
  <li>The same call works fine with postman.</li>
  <li>There is the csrf-token in my html head.</li>
  </ul>
  <p>Any suggestion?</p>