title: How can I parse event parametet in lambda?
body: <p>I am using Node.js 8.10 in lambda proxy integration.
  My goal is very simple. </p>
  
  <ol>
  <li>send json data to lambda function </li>
  <li>query rds with json data and retrive data from rds </li>
  <li>return response with json data in lambda from rds data.</li>
  </ol>
  
  <p>but I faced issue in step 1. I tried to figure out and I asked aws support center. it was not helpful. please help me.</p>
  
  <p>my test json data are :</p>
  
  <pre><code>{
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"
  }
  </code></pre>
  
  <p>my code is very simple but have a problem :</p>
  
  <pre><code>exports.handler = async (event) =&gt; {
      var body = JSON.parse(event)//&lt;--this is a problem
  
      let responseBody = {
          message: "hello",
          key1: body.key1
      };
      const response = {
          statusCode: 200,
          headers : {"Access-Control-Allow-Origin" : "*"},
          body: JSON.stringify(responseBody)
      };
      return response;
  };
  </code></pre>
  
  <p>I got this error in second line.</p>
  
  <pre><code>{"errorMessage":"Unexpected token o in JSON at position 1","errorType":"SyntaxError","stackTrace":["JSON.parse (&lt;anonymous&gt;)","exports.handler (/var/task/index.js:2:21)"]}
  </code></pre>
  
  <p>So I changed second line code like this.</p>
  
  <pre><code>var body = JSON.parse(JSON.stringify(event))
  </code></pre>
  
  <p>and then I got response well. I thought that's working well.</p>
  
  <pre><code>{
    "statusCode": 200,
    "headers": {
      "Access-Control-Allow-Origin": "*"
    },
    "body": "{\"message\":\"hello\",\"key1\":\"value1\"}"
  }
  </code></pre>
  
  <p>but I sent same json data with postman for real. but I got only this.</p>
  
  <p>{
      "message": "hello"
  }</p>
  
  <p>there isn't "key1". so I added console.log and then I checked log in cloudwatch.</p>
  
  <pre><code>{ message: 'hello', key1: undefined }
  </code></pre>
  
  <p>I can see aws editor log is well but when I send data with postman. lambda couldn't parse my json data. it means lambda couldn't parse event parameter.</p>
  
  <p>my questions are :
  1. when I tried to parse like this </p>
  
  <pre><code>var body = JSON.parse(event)"
  </code></pre>
  
  <p>why does lambda editor issue error? Is there something wrong? this is super simple and very common code.</p>
  
  <ol start="2">
  <li><p>How can I parse my json data and return correct value not undefined. I expected this response</p>
  
  <p>{ message: 'hello', key1: 'value1' }</p></li>
  </ol>
  
  <p>I have been trying to solve this for 3days. but I really have no idea. please help me out.</p>