title: Pass Data from React to node express server
body: <p>I am trying to pass the generalDetail  data from my react front end to my node server. I am currently getting a connection refused error. </p>
  
  <p>(OPTIONS <a href="http://localhost:5000/api/home" rel="nofollow noreferrer">http://localhost:5000/api/home</a> net::ERR_CONNECTION_REFUSED).</p>
  
  <p>here is my onSubmitForm function:</p>
  
  <pre><code>  onSubmitForm(e){
    e.preventDefault();
  
    let data = {
              generalDetail: this.state.generalDetails,
              firstName: this.state.firstName,
              middleName: this.state.middleName,
              lastName: this.state.lastName
        };
  
        axios.post("http://localhost:5000/home", data).then(() =&gt; {
  
         }).catch(() =&gt; {
            console.log("Something went wrong. Plase try again later");
        });
  
  
  }
    //end
  
    onContentChange(fieldname, data){
  
      console.log('On Content Change', data);
  
       this.setState({
         [fieldname]: data
  
      });
    }
  
  
  
  }
  </code></pre>
  
  <p>Here is my server.js file</p>
  
  <pre><code>const express = require('express');
  
  const app = express();
  
  
  // http://localhost:5000/api/home
  
  app.post('/api/home', (req, res) =&gt; {
    const data = [
      {req.body.generalDetail},
    ];
  
    res.json(data);
  });
  
  const port = 5000;
  
  app.listen(port, () =&gt; `Server running on port ${port}`);
  </code></pre>