Created
October 19, 2019 16:42
-
-
Save AndrewBestbier/e77fb7c56669f0f6211469b4101aec3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const AWS = require("aws-sdk"); | |
| const documentClient = new AWS.DynamoDB.DocumentClient(); | |
| exports.handler = async event => { | |
| const { | |
| pathParameters: { id } | |
| } = event; | |
| const { title } = JSON.parse(event.body); | |
| const params = { | |
| TableName: "events", | |
| Item: { | |
| id: id, | |
| title: title | |
| } | |
| }; | |
| try { | |
| const data = await documentClient.putItem(params).promise(); | |
| const response = { | |
| statusCode: 200 | |
| }; | |
| 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