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

main
Zed A. Shaw 9 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}); await ToDo.insert({task: req.body.task});
} }
// this is how you can prevent the annoying double submit await this.get(req, rep);
rep.code(200).send({message: "OK"});
} }
} }

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

Loading…
Cancel
Save