title: invalid JSON error when clicking button in reactjs
body: <p>I am trying to build a simple react page where there are two buttons at the beginning.
  The first sends the string 'private' as response when clicked, the second sends 'public' as a response when clicked.
  The two strings should come from a mongodb database. It's not done yet, because whenever I click on any of the buttons, I get the same error over and over again.
  It's the following:</p>
  <blockquote>
  <p>Uncaught (in promise) SyntaxError: Unexpected token '&lt;', &quot;&lt;!DOCTYPE &quot;... is not valid JSON</p>
  </blockquote>
  <p>This project has a backend server with two GET requests and a react frontend.
  You can see them below.
  The frontend:</p>
  <pre><code>function PubPrivBtn() {
  
  async function clickHandler(e) {
      if (e.target.id === 'pubBtn') {
          let response = await fetch('/api/public');
          let result = await response.json();
          console.log(result);
      }
      if (e.target.id === 'privBtn') {
          let response = await fetch('/api/private');
          let result = await response.json();
          console.log(result)
      }
  }
  return (
      &lt;div&gt;
          &lt;button onClick={(e) =&gt; clickHandler(e)} id='pubBtn'&gt;Public&lt;/button&gt;
          &lt;button onClick={(e) =&gt; clickHandler(e)} id='privBtn'&gt;Private&lt;/button&gt;
      &lt;/div&gt;
  )}export default PubPrivBtn;
  </code></pre>
  <p>And the backend:</p>
  <pre><code>import mongoose from &quot;mongoose&quot;;
  import express from &quot;express&quot;;
  import props from './porp.model.js'
  
  const app = express();
  app.use(express.json());
  
  mongoose.connect('mongodb://localhost/auth', async (err, db) =&gt; {
      if (err) {
          console.log(err)
      }
      else{
          console.log('Connected!')
      }
      app.get('/api/public', async (req, res) =&gt; {
          let pub = await props.where(&quot;vis&quot;).equals(&quot;public&quot;)
          console.log(pub);
          res.send(pub)
      })
  
      app.get('/api/private', async (req, res) =&gt; {
          let priv = await props.where(&quot;vis&quot;).equals(&quot;private&quot;)
          console.log(priv);
          res.send(priv)
      })
  })
  
  app.listen(3001)
  </code></pre>
  <p>Plus the schema is <code>const porp = new mongoose.Schema({ vis: String })</code>.</p>
  <p>I have tried to remake the whole project from zero (not like it was a big deal), but nothing changed, so I have to think the problem is not in my code. Or maybe I'm wrong and it's something obvious.</p>