title: How to update DynamoDB item using AWS Lambda and Axios
body: <p>I am trying to update a DynamoDB table item with Lambda and the below code works fine when the value is hardcoded.</p>
  
  <pre><code>const AWS = require('aws-sdk');
  const docClient = new AWS.DynamoDB.DocumentClient({region: "us-east-1"});
  
      exports.handler = (event, callback) =&gt; {
          const params = {
              Key: {
                  date: event.key1,
              },
              TableName: "todo-app",
              UpdateExpression:"SET task=:t",
              ExpressionAttributeValues:{":t":"This is my updated table"},
              ReturnValues:"UPDATED_NEW"
          };
  
          docClient.update(params, function(err, data) {
              if (err) {
                  console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
              } else {
                  console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
              }
          });
      };
  </code></pre>
  
  <p>However, this will always update the field with the hardcoded value of "This is my updated table". </p>
  
  <p><strong>Is there a way I can simply replace the "This is my updated table" to <code>event.key2</code> like so:</strong></p>
  
  <pre><code>const AWS = require('aws-sdk');
  const docClient = new AWS.DynamoDB.DocumentClient({region: "us-east-1"});
  
      exports.handler = (event, callback) =&gt; {
          const params = {
              Key: {
                  date: event.key1,
              },
              TableName: "todo-app",
              UpdateExpression:"SET task=:t",
              ExpressionAttributeValues:{":t":event.key2},
              ReturnValues:"UPDATED_NEW"
          };
  
          docClient.update(params, function(err, data) {
              if (err) {
                  console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
              } else {
                  console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
              }
          });
      };
  </code></pre>
  
  <p>And here is the axios function just in case:</p>
  
  <pre><code>  async handleEdit(){
      let task = prompt("Enter texty");
  
      await axios.post(
        'https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/default/serverlessToDoFunctionUPDATE',
        { key1: 1591926275608 },
        { key2: task },
      );
    };
  </code></pre>
  
  <p>I know this might sound like a silly question to some of you but I can't seem to find a simple working example. </p>
  
  <p>I'd appreciate any help with this. Thank you.</p>