title: Can't connect to NodeJS Express Server
body: <p>I can't connect to my Express server. I'm trying to use Axios to connect from my front end but it never reaches the endpoint. Also when I attempt to connect directly from the browser it just spins. When I start the server, I do see the console log message from the listen function, so it appears to be running. But the Axios.post never gets tot he /login route.</p>
  <p>Here is my index.js on the Server</p>
  <pre><code>const express = require('express');
  const app = express();
  const mysql = require('mysql');
  const cors = require('cors');
  
  app.use(cors);
  app.use(express.json());
  
  const db = mysql.createPool({
      host: 'localhost',
      user: 'root',
      password: 'root',
      databaseName: 'ncaa'
  });
  
  app.post(&quot;/login&quot;, (req, res) =&gt; {
      const userName = req.body.userName;
      const password = req.body.password;
  
      db.query(&quot;SELECT * from user where username = ? and password = ?&quot;, [userName, password], (err, result) =&gt; {
          if(err){
              res.send({err: err});
          }
          
          if (result){
              res.send(result);
          }
          else {
              res.send({message: &quot;Username or password is incorrect&quot;});
          }
      });
  });
  
  app.listen(3001, () =&gt; {
      console.log('App running on 3001');
  });
  </code></pre>
  <p>Here is my app.js on the client</p>
  <pre><code>import React from 'react';
  import { useState } from 'react';
  import Axios from 'axios';
  import './App.css';
  
  function App() {
    const [userName, setUserName] = useState(&quot;&quot;);
    const [password, setPassword] = useState(&quot;&quot;);
  
    const authenticateLogin = () =&gt; {
      Axios.post(&quot;http://localhost:3001/login&quot;, {
        userName: userName,
        password: password 
      }).then((response) =&gt; {
        console.log(response);
      });
      
    }
  
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;div className=&quot;login&quot;&gt;
          &lt;h1&gt;Login&lt;/h1&gt;
          &lt;label&gt;Username:&lt;/label&gt;
          &lt;input type=&quot;text&quot; onChange={(event) =&gt; { setUserName(event.target.value) }}/&gt;
          &lt;label&gt;Password:&lt;/label&gt;
          &lt;input type=&quot;password&quot; onChange={(event) =&gt; { setPassword(event.target.value) }}/&gt;
          &lt;button onClick = {authenticateLogin}&gt;Login&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>