File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 61
61
"id" : 18
62
62
},
63
63
{
64
- "subject" : " new todo " ,
64
+ "subject" : " new todo2 " ,
65
65
"completed" : true ,
66
66
"id" : 21
67
67
}
Original file line number Diff line number Diff line change 3
3
<div v-if =" loading" >
4
4
Loading..
5
5
</div >
6
- <form v-else >
6
+ <form
7
+ v-else
8
+ @submit.prevent =" onSave"
9
+ >
7
10
<div class =" row" >
8
11
<div class =" col-6" >
9
12
<div class =" form-group" >
@@ -55,9 +58,10 @@ export default {
55
58
const router = useRouter ();
56
59
const todo = ref (null );
57
60
const loading = ref (true );
61
+ const todoId = route .params .id
58
62
59
63
const getTodo = async () => {
60
- const res = await axios .get (' http://localhost:3000/todos/' + route . params . id );
64
+ const res = await axios .get (` http://localhost:3000/todos/${ todoId } ` );
61
65
62
66
todo .value = res .data ;
63
67
loading .value = false ;
@@ -75,11 +79,21 @@ export default {
75
79
76
80
getTodo ();
77
81
82
+ const onSave = async () => {
83
+ const res = await axios .put (` http://localhost:3000/todos/${ todoId} ` , {
84
+ subject: todo .value .subject ,
85
+ completed: todo .value .completed
86
+ });
87
+
88
+ console .log (res);
89
+ };
90
+
78
91
return {
79
92
todo,
80
93
loading,
81
94
toggleTodoStatus,
82
95
moveToTodoListPage,
96
+ onSave,
83
97
};
84
98
}
85
99
}
You can’t perform that action at this time.
0 commit comments