title: Pass Param Javascript to Node.js
body: <p>Trying to send a variable called "sitename" to Node.js </p>
  
  <pre><code>$(document).ready(function () {
      console.log(sitename);
      $.ajax({
          type: "POST",
          url: "/images",
          data: sitename,
          dataType: "json"
      })
          .done(function (json) {
              alert(json);
          });
  });
  </code></pre>
  
  <p><code>console.log(sitename)</code> gives me wanted <code>results = dagan</code></p>
  
  <p>Now on Node.js I have this code:</p>
  
  <pre><code>app.post('/images', function (req, res){
      console.log(req.body);
      var sitename= console.log(req.param.body);
      var BucketName = 'webwedding/'sitename;
      AWS.config.loadFromPath('./config.json');
      var s3 = new AWS.S3();
      var params = {Bucket: BucketName, Key: '*',ResponseContentType : 'application/json'};
      s3.getObject(params).
          on('httpData', function(chunk) {
              console.log(chunk);
              res.writeHead(200, {'Content-Type': 'text/html'});
              res.write('&lt;html&gt;&lt;body&gt;&lt;img src="data:image/jpeg;base64,')
              res.write(new Buffer(chunk).toString('base64'));
              res.end('"/&gt;&lt;&lt;/body&gt;&lt;/html&gt;');
          }).
          on('httpDone', function() { }).
          send();
  });
  </code></pre>
  
  <p>Well <code>console.log (req.body) gives me -&gt; **{ dagan: '' }**</code> and not <code>dagan</code>.</p>
  
  <p>The other one is undefined.</p>
  
  <p>2.Small Question-> Am I able to list a bucket/folder and get all object inside? if so any directions will be good, thanks Ahead!</p>
  
  <p><strong>SOLVED!</strong>
  adeneo, it's the correct answer "Use data: {sitename : sitename}, and req.param.sitename" ,thanks</p>
  
  <p>Just for the others that might have some issues with this, Client-Side: <code>data: {"sitename": sitename}</code>. Server-Side: <code>var sitename = req.param('sitename');</code>
  to be more specific :)</p>