title: How to solve this JSON promise error with ReactJS?
body: <p>I am new to React so there might be a lot of mistakes around. Also, I know there are similar questions, but none helped with my problem so far.</p>
  <p>I'm working on a project (using a template) that is using Java Spring (back-end) and ReactJS (front-end).
  At the moment I am trying to make a login form, and verify the credentials.</p>
  <p>These are the functions that I use when I press Login:</p>
  <pre><code>    onSubmit(){
          let login = {
              username: this.state.username,
              password: this.state.password
          };
          this.checkLogin(login);
      }
  
  
  
      checkLogin(login){
  
          return this.sendRequest(login, (result, status) =&gt; {
              console.log(&quot;AICI NU AJUNG CRED&quot;);
              if (result !== null &amp;&amp; (status === 200 || status === 201)) {
                  console.log(&quot;Successfully inserted person with id: &quot; + result);
                  this.reloadHandler();
              } else {
                  console.log(&quot;There was an error &quot; + result);
              }
          });
      }
  
  
      sendRequest(login, callback){
          let request = new Request(HOST.backend_api + endpoint.login + &quot;/login&quot;, {
              method: 'POST',
              headers : {
                  'Accept': 'application/json',
                  'Content-Type': 'application/json',
              },
              body: JSON.stringify(login)
          });
          console.log(request.url);
          console.log(login);
          RestApiClient.performRequest(request, callback);
      }
  
  
  function performRequest(request, callback){
  
      fetch(request)
          .then(
              function(response) {
                  if (response.ok) {
                      response.json().then(json =&gt; callback(json, response.status,null));
                  }
                  else {
                      response.json().then(err =&gt; callback(null, response.status,  err));
                  }
              })
          .catch(function (err) {
              //catch any other unexpected error, and set custom code for error = 1
              callback(null, 1, err)
          });
  }
  </code></pre>
  <p>I try it with a  &quot;test&quot; username and &quot;test&quot; password I have in my database.
  And this is the result:</p>
  <p><a href="https://i.stack.imgur.com/mPNWx.png" rel="nofollow noreferrer">dev console result 1</a></p>
  <p><a href="https://i.stack.imgur.com/c4yyQ.png" rel="nofollow noreferrer">dev console result 2</a></p>