Express.js proxy post request


I reviewed request module for node But can't figure out how to proxy POST request to remote server, example'/items', function(req, res){
  var options = {
      host: '',
      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});
Problem courtesy of: alexndm


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');'/items', function(req, res){'', 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


There is currently no discussion for this recipe.

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