title: VM1661:1 Uncaught (in promise) SyntaxError: Unexpected token s in JSON at position 0
body: <p>Hi guys there have been an error in my site for quite long and I have searched whole internet for the answers but didn't found any solutions here is my <strong>onsubmit</strong> code</p>
  <pre><code>onSubmit = () =&gt; {
      fetch(&quot;http://localhost:2000/signin&quot;, {
        method: &quot;post&quot;,
        headers: {
          &quot;Content-Type&quot;: &quot;application/json&quot;,
        },
        body: JSON.stringify({
          email: this.state.signinEmail,
          password: this.state.signinPassword,
        }),
      })
        .then((response) =&gt; response.json())
        .then(console.log(this.state.signinEmail, this.state.signinPassword))
        .then((data) =&gt; console.log(data));
    };
  </code></pre>
  <p>Also i have checked the response of the network tab it says success but getting this error don't know how to get rid of it. I have also checked the solution of the
  Stackoverflow that write <strong>Accept:application/json</strong> but still didn't worked,but it gives me &quot;bad request&quot; error
  The backend code is:</p>
  <pre><code>app.post(&quot;/signin&quot;, (req, res) =&gt; {
    if (
      req.body.email === database.users[0].email &amp;&amp;
      req.body.password === database.users[0].password
    ) {
      res.send(&quot;success&quot;);
    } else {
      res.status(400).json(&quot;error logging in&quot;);
    }
  });
   
  </code></pre>
  <p>I have also tested it through <strong>Postman</strong> it works successfully on it with no errors.
  This the json server.
  <a href="https://i.stack.imgur.com/3l4Yk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3l4Yk.png" alt="enter image description here" /></a></p>