title: AWS Lambda Parse JSON (Unexpected token)
body: <p>I am trying to get a Lambda function to access an API and return the JSON.</p>
  
  <h1>API</h1>
  
  <blockquote>
    <p><a href="http://api.openweathermap.org/data/2.5/weather?id=2172797&amp;appid=b1b15e88fa797225412429c1c50c122a" rel="nofollow">http://api.openweathermap.org/data/2.5/weather?id=2172797&amp;appid=b1b15e88fa797225412429c1c50c122a</a></p>
  </blockquote>
  
  <p>P.S This API ID is the demo one provided by OW. </p>
  
  <h1>Lambda Code</h1>
  
  <pre><code> var jsonurl = "http://api.openweathermap.org/data/2.5/weather?id=2172797&amp;appid=b1b15e88fa797225412429c1c50c122a";
   var data = JSON.parse(jsonurl);
   exports.handler = function(event, context) {
    console.log(data);
    context.done(null, data);  // SUCCESS with message
  };
  </code></pre>
  
  <h1>Error</h1>
  
  <pre><code>{
    "errorMessage": "Unexpected token h",
    "errorType": "SyntaxError",
    "stackTrace": [
      "Object.parse (native)",
      "Object.&lt;anonymous&gt; (/var/task/index.js:3:17)",
      "Module._compile (module.js:456:26)",
      "Object.Module._extensions..js (module.js:474:10)",
      "Module.load (module.js:356:32)",
      "Function.Module._load (module.js:312:12)",
      "Module.require (module.js:364:17)",
      "require (module.js:380:17)"
    ]
  }
  </code></pre>
  
  <h1>Log output</h1>
  
  <pre><code>START RequestId: 8ca0fbd1-eee5-11e5-b9dd-31048a8d5a45 Version: $LATEST
  Syntax error in module 'index': SyntaxError
      at Object.parse (native)
      at Object.&lt;anonymous&gt; (/var/task/index.js:3:17)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Module.require (module.js:364:17)
      at require (module.js:380:17)
  END RequestId: 8ca0fbd1-eee5-11e5-b9dd-31048a8d5a45
  REPORT RequestId: 8ca0fbd1-eee5-11e5-b9dd-31048a8d5a45  Duration: 173.76 ms Billed Duration: 200 ms     Memory Size: 128 MB Max Memory Used: 9 MB
  </code></pre>
  
  <p>Can anyone see the problem?</p>
  
  <p>What I would like is for lambda to get the json and return it, so anyone looking at my API url will see the results from the Open Weather API</p>