Express.js proxy post request

Problem

I reviewed request module for node https://github.com/mikeal/request But can't figure out how to proxy POST request to remote server, example

app.post('/items', function(req, res){
  var options = {
      host: 'https://remotedomain.com',
      path: '/api/items/,
      port: 80
    };
    var ret = res;
    http.get(options, function(res){
      var data = '';
      res.on('data', function(chunk){
        data += chunk;    
      });

      res.on('end', function(){
        var obj = JSON.parse(data);
        ret.json({obj: obj});
        console.log('end');
      });
    });
});
Problem courtesy of: alexndm

Solution

Unless I am missing something from your question, you can just do a simple post, and then do something with the response data:

var request = require('request');

app.post('/items', function(req, res){

   request.post('https://remotedomain.com/api/items', function (error, response, body) {

   if (!error && response.statusCode == 200) {
     console.log(body); // Print the body of the response. If it's not there, check the response obj
     //do all your magical stuff here
   }
})
Solution courtesy of: Jamis Charles

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.