title: How do I send data from React to Node server and back result to React?
body: <p>How may I send data from React to Node server and back result to React?
  I have form on react, and have some data from form, I want to send this data to node server change this data and return result to react.</p>
  
  <p><strong>React code:</strong></p>
  
  <pre><code>var Exp = React.createClass({
  getInitialState: function () {
      return {count: ""};
  },
  
  handleChange: function (event) {
      this.setState({count: event.target.value});
  },
  render: function () {
      return &lt;div&gt;
          &lt;h1&gt;Count: {this.state.count}&lt;/h1&gt;
  
          &lt;form method="post"&gt;
              &lt;input type="text" onChange={this.handleChange}/&gt;
              &lt;button onClick={this._onChange}&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;;
  },
  _onChange: function (event) {
      event.preventDefault();
      console.log("count: " + this.state.count);
  }});React.render(&lt;Exp /&gt;, document.getElementById('container'));
  </code></pre>
  
  <p><strong>Node:</strong></p>
  
  <pre><code>var express = require('express');
  var mathjs = require('mathjs');
  var bodyParser = require('body-parser');
  var app = express();
  app.use(bodyParser());
  app.get('/', function (req, res) {
  
  var html = '&lt;form action="/" method="post"&gt;' +
      '&lt;input type="text" name="expression"  /&gt;' +
      '&lt;br&gt;' +
      '&lt;button type="submit"&gt;Submit&lt;/button&gt;' +
      '&lt;/form&gt;';
  
  res.send(html);});
  
  app.post('/', function (req, res) {
  
  var expResult = mathjs.eval(req.body.expression);
  
  var html = 'Result: ' + expResult + '.&lt;br&gt;' +
      '&lt;a href="/"&gt;Try again.&lt;/a&gt;';
  res.send(html);});
  
  app.listen(3333);
  </code></pre>