title: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 (React/Redux App)
body: <p>I am trying to signup/login a user using JWT. For this I have a working API which I have created.</p>
  <p>Now, I want to use that authentication API with my React/Redux App.</p>
  <p>When a user signs up I <code>dispatch</code> an action from my Signup component -</p>
  <pre><code>const signUpHandler = (e) =&gt; {
      e.preventDefault();
  
      dispatch(signup(name, email, password));
    };
  </code></pre>
  <p>Now, in my <code>userSlice</code> I have the following reducer -</p>
  <pre><code>signup: (state, action) =&gt; {
        fetch(&quot;http://localhost:5000/user/signup&quot;, {
          method: &quot;POST&quot;,
          headers: {
            &quot;Content-Type&quot;: &quot;application/json&quot;,
          },
          body: JSON.stringify(action.payload),
        })
          .then((res) =&gt; {
            return res.json();
          })
          .then((data) =&gt; {
            console.log(data);
          });
      },
  </code></pre>
  <p>After I click on Signup i.e; after the <code>fetch</code> process begins, I get this error -</p>
  <p><strong>Uncaught (in promise) SyntaxError: Unexpected token &lt; in JSON at position 0</strong></p>
  <p>After digging in a little bit, I found that this error occurs when the return type from <code>fetch</code> is not JSON. But my API works prefectly fine.</p>
  <p>Any idea what might be the issue?</p>
  <p>Thanks in advance.</p>