Simplify it a bit more by having POST return the todo list again.

main
Zed A. Shaw 3 months ago
parent bafff1d25f
commit 825378c2b6
  1. 3
      controllers/todo_alpine.js
  2. 3
      templates/todo_alpine.html

@ -25,8 +25,7 @@ export class Todo {
await ToDo.insert({task: req.body.task});
}
// this is how you can prevent the annoying double submit
rep.code(200).send({message: "OK"});
await this.get(req, rep);
}
}

@ -6,8 +6,7 @@
<script>
const new_task = async (todos, task) => {
// zero error handling but fine for now
await axios.post("/todo_alpine", {task});
return (await axios.get('/todo_alpine')).data;
return (await axios.post("/todo_alpine", {task})).data;
}
</script>

Loading…
Cancel
Save