title: Get POST data from request
body: <p>I need to extract POST data from a request I'll receive (using Slack Slash Commands, I basically want to check the channel where the command's been called and only execute it in some particular channels).</p>
  
  <p>I'm relatively new to NodeJs, so I'm usually quite lost around requests and the like, precise help is welcome.</p>
  
  <p>(Small detail: when trying out different methods, I noticed that if I requested say, <em>response.js</em> from Slack, Slack wouldn't display the same logs that I see in shell, rather displaying the entire code in chat. Am I doing something wrong?)</p>
  
  <p>Edit: I'm using Express.</p>
  
  <p>Edit 2 : added <code>request.js</code> and <code>response.js</code></p>
  
  <p><code>request.js</code> :</p>
  
  <pre><code>var request = require('request');
  var requestData = {
      "token" : "XXXXXXXX",
      "team_id" : "XXXXX"
  }
  var options = {
      url : 'http://XX.XXX.XX.XX/request/response.js',
      method : 'POST',
      json : requestData
  }
  
  request(options, function(err, res, body) {
      console.log("requesting");
      if (err)
          console.log("error, mate");
      else
          console.log("no worries");
  })
  </code></pre>
  
  <p><code>response.js</code> :</p>
  
  <pre><code>const express = require('express')
  const app = express()
  
  var bodyParser = require('body-parser');
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  
  app.post('/request/response.js', function (req, res) {
      var post_body = req.body;
      console.log(post_body);
  })
  
  app.listen(3000, function() {
      console.log("listening");
  })
  </code></pre>