title: Parsing JSON data from a URL
body: <p>I'm trying to create  function that can parse JSON from a url. Here's what I have so far:</p>
  
  <pre><code>function get_json(url) {
      http.get(url, function(res) {
          var body = '';
          res.on('data', function(chunk) {
              body += chunk;
          });
  
          res.on('end', function() {
              var response = JSON.parse(body);
                  return response;
          });
      });
  }
  
  var mydata = get_json(...)
  </code></pre>
  
  <p>When I call this function I get errors. How can I return parsed JSON from this function?</p>