title: Return json body in REQUEST nodejs
body: <p>I'm using the <code>request</code> module to make an HTTP GET request to an url in order to get a JSON response.</p>
  
  <p>However, my function is not returning the response's body.</p>
  
  <p>Can someone please help me with this?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>router.get('/:id', function(req, res) {
    var body= getJson(req.params.id);
    res.send(body);
  });
  </code></pre>
  
  <p>Here is my <code>getJson</code> function:</p>
  
  <pre><code>function getJson(myid){
    // Set the headers
    var headers = {
     'User-Agent':       'Super Agent/0.0.1',
     'Content-Type':     'application/x-www-form-urlencoded'
    }
    // Configure the request
    var options = {
      url: 'http://www.XXXXXX.com/api/get_product.php',
      method: 'GET',
      headers: headers,
      qs: {'id': myid}
    }
  
    // Start the request
    request(options, function (error, response, body) {
    if (!error &amp;&amp; response.statusCode == 200) {
      return body;
    }
    else
      console.log(error);
    })
  }
  </code></pre>