title: Value of map from DynamoDB is undefined in Node.js
body: <p>I have a Lambda function which runs in Node.js 4.3. The input parameter of the function is a String, which is being sent from an AWS Lex bot.</p>
  
  <p>I want to get an item from a DynamoDB table. In this item I have a Map-type attribute, which contains a String key and String value. I want to get a value from that map using the key String I got as a parameter at the start of the function.</p>
  
  <p>The problem is that when I log the map to the console, all I see there is <code>{}</code>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>var AWS = require('aws-sdk');  
  AWS.config.region = 'us-east-1';
  var dynamodb = new AWS.DynamoDB();
  
  const sessionAttributes = intentRequest.sessionAttributes;
  const slots = intentRequest.currentIntent.slots;
  const name = slots.names;
  
  var id = null;
  if (name == "a") {
      id = "00";
  } else if (name == "b") {
      id = "01";
  }
  
  var params = {
      TableName: 'names',
      Key: {
          'id' : {S: 'test-id'}
      }
  };
  
  var names = {};
  
  dynamodb.getItem(params, function(err, data) {
      if (err) {
          console.log(err); // an error occurred
      } else {
          names = data.Item.names.M;
      }
  });
  
  console.log(names);
  
  var content = names[id];
  
  callback(close(sessionAttributes, 'Fulfilled',
  {'contentType': 'PlainText', 'content': content}));
  </code></pre>
  
  <p>As you can see, there is a <code>console.log</code> line at the end of the code. This line logs just <code>{}</code>. The final message's content is <code>undefined</code>.</p>
  
  <p>What can I do to fix this?</p>