Skip to content

Commit

Permalink
todomvc: consistent first item uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
DJankauskas committed Jul 28, 2023
1 parent 491a938 commit d36b8f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion todomvc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ app.get("/items", (req, res) => {

app.post("/items", (req, res) => {
// Note: no validation here!
const id = crypto.randomUUID();
const id =
items.size === 0
? "ed76baac-7b44-4a11-b345-56384ffa8ad8"
: crypto.randomUUID();
console.log("got body", req.body);
const newItem = { id, ...req.body };
items.set(id, newItem);
Expand Down

0 comments on commit d36b8f7

Please sign in to comment.