Skip to content

Commit e0a5ee2

Browse files
committed
feat: added delete todo function.
1 parent 95b39a5 commit e0a5ee2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

todos/routes.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,21 @@ router
115115
});
116116
})
117117
.delete((req, res) => {
118-
res.end("delete");
118+
console.log(new Date().getTime());
119+
const params = Object.assign({}, tableParams, {
120+
Key: {
121+
id: req.params.id
122+
}
123+
});
124+
125+
dynamoDb.delete(params, error => {
126+
if (error) {
127+
console.error(error);
128+
res.status(501).send({ error: "Could not delete toto item" });
129+
} else {
130+
res.status(204).send();
131+
}
132+
});
119133
});
120134

121135
routes.use(bodyParser.json({ strict: false }));

0 commit comments

Comments
 (0)