Created
December 25, 2018 23:30
-
-
Save jdstaerk/27a2369620376fc025ee6a70accd13b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| const axios = require("axios"); | |
| export default { | |
| name: "ToDo", | |
| data() { | |
| return { | |
| todos: [], | |
| todo: { | |
| Content: '', | |
| DueDate: '' | |
| } | |
| }; | |
| }, | |
| methods: { | |
| submitTodo: function() { | |
| axios | |
| .post("/todo", this.todo) | |
| .then(response => { | |
| this.getTodos(); | |
| }); | |
| }, | |
| getTodos: function() { | |
| axios | |
| .get("/todos") | |
| .then(response => { | |
| this.todos = response.data; | |
| }) | |
| .catch(error => console.error(error)); | |
| }, | |
| finishToDo: function(todo) { | |
| axios | |
| .delete("/todo", { | |
| data: { | |
| id: todo._id | |
| } | |
| }) | |
| .then(async response => { | |
| if (response.status === 200) { | |
| this.getTodos(); | |
| } | |
| }) | |
| .catch(error => console.error(error)); | |
| } | |
| }, | |
| mounted() { | |
| this.getTodos(); | |
| } | |
| }; | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment