Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

practice/005001_answer #1

Open
wants to merge 1 commit into
base: practice/005001_base
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/ToDo.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="todo w3-container w3-center">
<label>{{index + 1}}.- {{todo.title}}</label>
<input class="w3-check" type="checkbox" v-model="todo.completed">
<input class="w3-check" type="checkbox" v-model="todo.completed" @change="updateTodo">
<hr>
</div>
</template>
Expand All @@ -17,6 +17,20 @@ export default {
type: Number,
required: true
}
},
methods: {
async updateTodo(e) {
let id = this.todo.id;
let completed = e.target.checked;
let data = {
completed
}
let response = await fetch(`http://localhost:3000/api/task/${id}`, {
method: 'put',
headers: {"Content-Type": "application/json"},
body: JSON.stringify(data)
});
}
}
}
</script>
Expand Down