title: REACT fetch post request
body: <p>I have problem with routing post request
  I need to build register form and post input from form to mongodb
  I made router and post route on server side and it works ok (when I use postman)</p>
  
  <p>//form is required model​
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>router.route('/').post(function(req,res,next){
   res.send(req.body)
   form.create(
    {"first_name": req.body.first_name,
    "last_name": req.body.last_name
   })
    .then(function(data){ 
    res.send(data);
    console.log(data);
   }).catch(function(err){console.log(err)});
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I need to fire it form client side, not postman. And here i am lost. I can do it with  but when i add onSubmit action it doesnt work. And I need to use new function to fire another thing without redirecting to another page. How to pass this.refs.first_name.value to body so that i could use fetch function?? 
  Below react component</p>
  
  <p>added this JavaScript/JSON snippet</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>export default class Form extends React.Component {
   constructor(props){
    super(props);
    this.handleSubmit = this.handleSubmit.bind(this);
   }
   handleSubmit(event){ 
    event.preventDefault();
    console.log(this.refs.first_name.value);
    fetch('/', {
     method: 'post',
     body: {
      "first_name": this.refs.first_name.value
     }
    });
   };
   render () {
    return (
     
     &lt;div id="signup"&gt;
      &lt;form onSubmit={this.handleSubmit}&gt;
          &lt;input ref="first_name" placeholder="First Name" type="text" name="first_name"/&gt;&lt;br /&gt;
          &lt;input placeholder="Last Name" type="text" name="last_name"/&gt;&lt;br /&gt;
         &lt;button type="Submit"&gt;Start&lt;/button&gt;
      &lt;/form&gt;
  ​
     &lt;/div&gt;
  ​
    )
   }
  }</code></pre>
  </div>
  </div>
  </p>