title: How to fetch and display data from mssql database using react and express?
body: <p>So basicaly I have a mssql database with customers, project and task lists and I need to fetch and display the data in a table form using react and express.</p>
  
  <p><a href="https://i.stack.imgur.com/pVJ43.png" rel="nofollow noreferrer">https://i.stack.imgur.com/pVJ43.png</a></p>
  
  <p>So far I managed to connect to my database using express and I can display that info in json format using express in backend but the next thing I have to do is to display it on the frondend using react.</p>
  
  <p>So far my code in react looks like this:</p>
  
  <pre><code>import React, { Component } from 'react';
  import logo from './logo.svg';
  import './App.css';
  
  class App extends Component {
  
  state = { users: [] }
  
  componentDidMount() {
  fetch('/users')
    .then(res =&gt; res.json())
    .then(users =&gt; this.setState({ users }));
  }
  
  
  render() {
  return (
    &lt;div&gt;
      &lt;h1&gt;Users&lt;/h1&gt;
      &lt;ul&gt;
        {this.state.users.map(user =&gt;
          &lt;li key={user.id}&gt;{user.username}&lt;/li&gt;
        )}
      &lt;/ul&gt;
    &lt;/div&gt;
  );
  }
  }
  
  export default App;
  </code></pre>
  
  <p>The error I'm getting in react and the compiled version:</p>
  
  <blockquote>
    <p><strong>Unhandled Rejection (SyntaxError): Unexpected token P in JSON at position 0</strong></p>
  </blockquote>
  
  <p>Ref: <a href="https://i.stack.imgur.com/pzA4Z.png" rel="nofollow noreferrer">React</a> and <a href="https://i.stack.imgur.com/J6DXW.png" rel="nofollow noreferrer">complied version</a></p>
  
  <p>So, how do I connect my backend with frontend using just these two frameworks ?</p>
  
  <p>Thanks in advance !</p>