Skip to content

Commit 648a14c

Browse files
committed
feat: added list todos function.
1 parent b9504fc commit 648a14c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

todos/routes.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ const tableParams = {
1515
router
1616
.route("/todos")
1717
.get(function list(req, res) {
18-
res.send("list");
18+
dynamoDb.scan(tableParams, (error, result) => {
19+
if (error) {
20+
console.error(error);
21+
res
22+
.statusCode(error.statusCode || 501)
23+
.send({ error: "Couldn't fetch the todos." });
24+
} else {
25+
res.send(result.Items);
26+
}
27+
});
1928
})
2029
.post(function create(req, res) {
2130
const timestamp = new Date().getTime();

0 commit comments

Comments
 (0)