Skip to content

Instantly share code, notes, and snippets.

@jdstaerk
Created December 25, 2018 23:30
Show Gist options
  • Select an option

  • Save jdstaerk/27a2369620376fc025ee6a70accd13b9 to your computer and use it in GitHub Desktop.

Select an option

Save jdstaerk/27a2369620376fc025ee6a70accd13b9 to your computer and use it in GitHub Desktop.
<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