how to get items in dynamodb nodejs

const AWS = require('aws-sdk');

// Set the AWS region and credentials if not configured globally
AWS.config.update({ region: 'your-region', accessKeyId: 'your-access-key', secretAccessKey: 'your-secret-key' });

// Create a DynamoDB DocumentClient
const docClient = new AWS.DynamoDB.DocumentClient();

// Define the parameters for the DynamoDB query
const params = {
  TableName: 'YourTableName',
  KeyConditionExpression: '#primaryKey = :primaryKeyValue',
  ExpressionAttributeNames: {
    '#primaryKey': 'yourPrimaryKeyAttribute',
  },
  ExpressionAttributeValues: {
    ':primaryKeyValue': 'desiredPrimaryKeyValue',
  },
};

// Execute the query and handle the response
docClient.query(params, (err, data) => {
  if (err) {
    console.error('Error querying DynamoDB:', err);
  } else {
    console.log('Query succeeded:', data.Items);
  }
});

Note: Replace 'your-region', 'your-access-key', 'your-secret-key', 'YourTableName', 'yourPrimaryKeyAttribute', and 'desiredPrimaryKeyValue' with your specific AWS region, access key, secret key, DynamoDB table name, primary key attribute, and desired primary key value, respectively.