title: TypeError: JSON.stringify(...).then is not a function - React JS
body: <p>I am trying to connect my react app with the backend for log in page. I am using a promise to return a success message. </p>
  
  <p>login.js </p>
  
  <pre><code>    onSubmitSignIn = () =&gt; {
          fetch('http://localhost:5000/', {
                method : 'post',
                headers :{ 'Content-Type' : 'application/json'},
                body : JSON.stringify({
                     userId : this.state.userId,
                     password : this.state.password
               }).then(response =&gt; response.json())
                 .then(data =&gt; {
                      if(data === 'success'){
                              this.props.onRouteChange('home');
                      }
               })
          })
      }
  </code></pre>
  
  <p>Backend code - </p>
  
  <pre><code>  exports.findById = (req) =&gt; {
           return new Promise((resolve) =&gt; {
                 var sql = "Select * from users where userid = '" + req.body.userId + "' ;";
                 connection.query(sql,req,  function (error, results, fields) {
                      var data = JSON.parse(JSON.stringify(results)); 
                      var valid = false; 
                      if( data.length !=0 &amp;&amp; req.body.userId === data[0].userid &amp;&amp; req.body.password === data[0].password)
                           valid = true; 
  
                      if(valid) {
                           resolve({message : "success"});
                      }else{
                           reject({ message :"fail"});
                      }
                });
          })
    };
  </code></pre>
  
  <p>After clicking on sign in button, I am getting an error <strong>"TypeError: JSON.stringify(...).then is not a function"</strong></p>
  
  <p>I tried some solutions from similar questions, it did not work in my case. </p>