title: How to make an axios post to database?
body: <p>I'm trying to make a login system which is part of my project with react, express, MySQL and Axios but I keep getting this error- Uncaught (in promise) Error: Request aborted</p>
  <p>Server side:</p>
  <pre><code>const express = require(&quot;express&quot;);
  const cors = require(&quot;cors&quot;);
  const mysql = require(&quot;mysql&quot;);
  
  const app = express();
  app.use(express.json())
  app.use(cors());
  
  const db = mysql.createConnection({
      host: &quot;localhost&quot;,
      user: &quot;root&quot;,
      password: &quot;cool12345&quot;,
      database: &quot;users&quot;
  })
  
  db.connect(err =&gt; {
      if(err){
          return err;
      }
  })
  
  console.log(db)
  
  
  app.post(&quot;/register&quot;, (req, res) =&gt; {
      const username = req.body.username;
      const password = req.body.password;
      const email = req.body.email;
  
      db.query(&quot;INSERT INTO teachers (name, email, password) VALUES (?,?)&quot;, [username, email, password], (error, result) =&gt; {
          console.log(error)
      })
   
      db.query(&quot;INSERT INTO teachers (name, email, password) VALUES ('test', 'test2', 'test3')&quot;)
  })
   
  
  app.listen(4000, () =&gt; {
      console.log(&quot;Listening on port 4000&quot;)
  })
  </code></pre>
  <p>client side:</p>
  <pre><code>import React, { useState } from 'react'
  import &quot;../styling/SignUp.css&quot;;
  import { useHistory } from &quot;react-router-dom&quot;
  import Axios from &quot;axios&quot;;
  
  
  
  function SignUp() {
      const [usernameReg, setUsernameReg] = useState(&quot;&quot;)
      const [emailReg, setEmailReg] = useState(&quot;&quot;)
      const [passwordReg, setPasswordReg] = useState(&quot;&quot;)
  
      const register = () =&gt; {
          Axios.post(&quot;https://localhost:4000/register&quot;, {username: usernameReg, email:emailReg, password: passwordReg}).then((response) =&gt; {
              console.log(response)
          })
      }
  </code></pre>
  <p>the function in the client-side returns a form but there's too much code so I left it out of this question. The signup button has an onClick handler function which runs the register.</p>