title: Node.js read post data from Express with Socket.io and Http
body: <p>I have a node.js server with Express and Socket.io.
  In The Socket.io docs i found this example code for host server.</p>
  
  <p>My problem is now the next:
  I cant read Post data from the requests.</p>
  
  <p>There is a request:</p>
  
  <pre><code>            $.ajax({
                  type: "POST",
                  url: "http://127.0.0.1:4444/login",
                  data: {
                      da: 'a'  
                  },
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function(data){
                      console.log(data);
  
                  },
                  failure: function(errMsg) {
                      console.log(data);
                  }
              });
  </code></pre>
  
  <p>And this is the server:</p>
  
  <pre><code>var app = require('express')();
  var server = require('http').Server(app);
  var io = require('socket.io')(server);
  server.listen(4444);
  
  var database = require('./database.js');
  database.methods.connect(); 
  
  
  // Add headers
  app.use(function (req, res, next) {
      res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8080');
      res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
      res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
      res.setHeader('Access-Control-Allow-Credentials', true);
      next();
  });
  
  app.post('/login', function(req, res) {
      console.log(req.body);
  });
  </code></pre>
  
  <p>I tried a lot of thinks. For example: bodyParser.json(), bodyParser.urlencoded</p>
  
  <p>But this express is run with require("http");</p>
  
  <p>How can i read the body from the request?
  I hope someone can help me!
  Thanks</p>