title: TypeError: Network request failed using fetch ReactNative and Laravel response
body: <p>I am posting data to Laravel and expect a success response, but it catches the exception <strong>TypeError: Network request failed</strong>. <em>Using get methods and login post methods using Laravel passport works all fine.</em></p>
  
  <ul>
  <li>Adding 'Content-Type': 'application/json' to headers creates Network request failed for the login methods.</li>
  <li>Postman returns valid errors or success, so works totally as expected.</li>
  <li>Debugging showed that the request has been sent to Laravel and routing is correct as Visual Studio Code debugger stops at a breakpoint at return response. </li>
  </ul>
  
  <pre class="lang-php prettyprint-override"><code>public function postMessages()
  {
      ...
  
      return response()-&gt;json(['success' =&gt; 'success'], 200);
  }
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>Route::middleware('auth:api')-&gt;group(function () {
      Route::post('messages', 'Api\ChatController@postMessages');
  });
  </code></pre>
  
  <pre><code>export const fetchApi = async (endPoint, method = 'get', body = {}) =&gt; {
      const accessToken = authSelectors.get().tokens.access.value;
      const accessType = authSelectors.get().tokens.access.type;
      let headers = {
        ...(accessToken &amp;&amp;
        {
          Authorization: `${accessType} ${accessToken}`
        } 
        )
      };
      let response;
      if (method=='get' || Object.keys(body)==0 ) {
          response = await fetch(`${apiConfig.url}${endPoint}`, {
              method: method,
              headers: headers
          });
      } else {
          var formData = new FormData();
          Object.keys(body).forEach(type =&gt; {
              formData.append(type, body[type]);
          });
          response = await fetch(`${apiConfig.url}${endPoint}`, {
              method: method,
              headers: headers,
              body: formData
          });
          console.log('fetch response: ' + JSON.stringify(response));
      }
      let responseJsonData = await response.json();
      return responseJsonData;
  }
  </code></pre>
  
  <pre><code>export const postMessages = (eidug, type, name, messages) =&gt; fetchApi('/message', 'post', {
      'eidug': eidug,
      'type': type,
      'name': name,
      'messages': messages
  });
  </code></pre>
  
  <p>I expect a response without any exception like Postman. What can be going wrong?</p>