title: Parsing JSON file using Lambda
body: <p>My main objective is to parse a JSON file and write the content of the JSON file to a scrollable list in the browser. I created a JSON file and stored it in an S3 bucket. I then created the following Lambda function:</p>
  
  <pre><code>// ----receive function----v
  function get_json(url, callback) {
      http.get(url, function(res) {
          var body = '';
          res.on('data', function(chunk) {
              body += chunk;
          });
  
          res.on('end', function() {
              var response = JSON.parse(body);
              // call function ----v
              callback(response);
          });
      });
  }
  
  var mydata = get_json("https://s3.amazonaws.com/scrollablelist/scrollableList.json", function (resp) {
      console.log(resp);
  });
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>{
    "errorMessage": "http is not defined",
    "errorType": "ReferenceError",
    "stackTrace": [
      "Object.&lt;anonymous&gt; (/var/task/index.js:20:18)",
      "Module._compile (module.js:570:32)",
      "Object.Module._extensions..js (module.js:579:10)",
      "Module.load (module.js:487:32)",
      "tryModuleLoad (module.js:446:12)",
      "Function.Module._load (module.js:438:3)",
      "Module.require (module.js:497:17)",
      "require (internal/module.js:20:19)"
    ]
  }
  </code></pre>
  
  <p>The Log Output says this:</p>
  
  <pre><code>START RequestId: 516f164b-7ee3-11e7-97a7-0373caaf493b Version: $LATEST
  module initialization error: ReferenceError
      at get_json (/var/task/index.js:3:9)
      at Object.&lt;anonymous&gt; (/var/task/index.js:20:18)
      at Module._compile (module.js:570:32)
      at Object.Module._extensions..js (module.js:579:10)
      at Module.load (module.js:487:32)
      at tryModuleLoad (module.js:446:12)
      at Function.Module._load (module.js:438:3)
      at Module.require (module.js:497:17)
      at require (internal/module.js:20:19)
  END RequestId: 516f164b-7ee3-11e7-97a7-0373caaf493b
  REPORT RequestId: 516f164b-7ee3-11e7-97a7-0373caaf493b  Duration: 80.81 ms          Billed Duration: 100 ms     Memory Size: 128 MB Max Memory Used: 19 MB  
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>