title: app.js:40 Uncaught (in promise) SyntaxError: Unexpected end of input
body: <p>while running, my react app, the browser's console is showing the error like</p>
  <blockquote>
  <p>app.js:40 Uncaught (in promise) SyntaxError: Unexpected end of input</p>
  </blockquote>
  <p>kindly help me I'm stuck in this error for 1 month and I suffered a lot of online solutions but nothing helped.</p>
  <p><strong>This is my app.js file in reactjs app</strong></p>
  <pre><code>fetch('http://localhost:8080/expenseitem', 
      {
          mode: 'no-cors',
          creadentials: 'same-origin',
          headers: {
              'Content-Type': 'application/json',
              &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;,
              &quot;Access-Control-Allow-Credentials&quot; : true
          }
      }).then(response =&gt; response.json()
        
      ).then(
          data =&gt; {
              console.log('success',  data);
              // setExpenses(data)
          }
      );
  </code></pre>
  <p><strong>This is my Api file</strong></p>
  <pre><code>const Joi = require('joi');
  const express = require('express');
  const res = require('express/lib/response');
  const app = express();
  const PORT = 8080;
  app.use(express.json());
  
  
  const expenseitem = [
      {
          id: 1, title: 'Books', amount: '300',
          date: new Date(2022, 5, 12)
      },
      {
          id: 2, title: 'Food', amount: '800',
          date: new Date(2022, 5, 12)
      },
      {
          id: 3, title: 'Shooping', amount: '1 lakh',
          date: new Date(2022, 5, 12)
      },
      {
          id: 4, title: 'Grocaries', amount: '90,000',
          date: new Date(2022, 5, 12)
      },
      {
          id: 5, title: 'Accesencories', amount: '30,000',
          date: new Date(2022, 5, 12)
      },
      { id: 6, title: 'laptop', amount: '90,000',
      date: new Date(2022, 5, 6)},
  ];
  
  
  app.get('/', (req, res) =&gt; {
      res.send('hello shreya');
  });
  
  app.get('/expenseitem/', (req, res) =&gt; {
      res.send(expenseitem);
      res.set({
          &quot;Content-Type&quot;: &quot;application/json&quot;,
          &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;,
          &quot;Access-Control-Allow-Credentials&quot; : true 
      });
  });
  
  app.get('/expenseitem/:id', (req, res) =&gt; {
      const expense = expenseitem.find(c =&gt; c.id === parseInt(req.params.id));
      if (!expense) res.status(404).send('The expense with given is is not found');
      res.send(expense);
  })
  app.post('/expenseitem/', (req, res) =&gt; {
  
      const { error } = validateExpense(req.body);
      if (error) {
          res.status(400).send(result.error.details[0].message);
          return;
      }
      const expense = {
          id: expenseitem.length + 1,
          title: req.body.title
      };
  
      expenseitem.push(expense);
      res.send(expense);
  });
  
  
  app.put('/expenseitem/:id', (req, res) =&gt; {
      const expense = expenseitem.find(c =&gt; c.id === parseInt(req.params.id));
      if (!expense) res.status(404).send('The expense with given ID is not found')
      expense.title = req.body.title;
      res.send(expense);
  });
  
  function validateExpense(expense) {
      const schema = {
          title: Joi.string().min(3).required()
      };
  
  }
  
  const port = process.env.PORT || 8080;
  app.listen(port, () =&gt; console.log(`its live on http://localhost:${PORT}`));
  
  </code></pre>