Skip to content

Instantly share code, notes, and snippets.

@AndrewBestbier
Created October 19, 2019 16:40
Show Gist options
  • Select an option

  • Save AndrewBestbier/c185637d76d7133f6abc782b958933b0 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewBestbier/c185637d76d7133f6abc782b958933b0 to your computer and use it in GitHub Desktop.
const AWS = require("aws-sdk");
const documentClient = new AWS.DynamoDB.DocumentClient();
exports.handler = async event => {
const {
pathParameters: { id }
} = event;
const params = {
TableName: "events",
Key: { id }
};
try {
const data = await documentClient.get(params).promise();
const response = {
statusCode: 200,
body: JSON.stringify(data.Item)
};
return response;
} catch (e) {
return {
statusCode: 500
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment