Good afternoon everyone, Any idea how to extract a field from the returnd data array in node.js Many thanks

exports.handler = (event, context, callback) => {
var countryName ="YECO";// event.currentIntent.slots.ctryName;

var params = {TableName: 'DynamoDBTutorial', Key:{"id":countryName}}

dotClient.get(params,function(err,data){
  if(err){
    callback(err,null);
  }
  else{
    callback(null,data); //<< how can I fetch first field eg. data[0]

Here's what I currently get which's correct but I want to fetch key1 value
{
  "Item": {
    "key1": "100",
    "key2": "200",
    "id": "YECO",
    "key3": "300"
  }
}

1 Answers

0
dashmug On Best Solutions

You can replace callback(null,data) with callback(null, data.Item.key1).