Skip to content

Commit b9504fc

Browse files
committed
refactor: refactor create function.
1 parent 6770d95 commit b9504fc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

todos/routes.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const router = express.Router();
88

99
const dynamoDb = new AWS.DynamoDB.DocumentClient();
1010

11-
const params = {
11+
const tableParams = {
1212
TableName: process.env.DYNAMODB_TABLE
1313
};
1414

@@ -33,15 +33,16 @@ router
3333
updateAt: timestamp
3434
};
3535

36-
const createParam = Object.assign({}, params, { Item: Item });
36+
const params = Object.assign({}, tableParams, { Item: Item });
3737

38-
dynamoDb.put(createParam, err => {
39-
if (err) {
40-
console.error(err);
38+
dynamoDb.put(params, error => {
39+
if (error) {
40+
console.error(error);
4141
res.status(400).send("Couldn't create todo item.");
42+
} else {
43+
res.send(params);
4244
}
4345
});
44-
res.send(createParam);
4546
});
4647

4748
router

0 commit comments

Comments
 (0)