-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.ts
32 lines (28 loc) · 854 Bytes
/
todo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import ApiService from "../services/ApiService"
export const addTodo = async (task: string)=>{
try {
const response = await ApiService.post(`/addTodo`, {
task:task
})
console.log("AddTodo response: ", response.data)
return response.data
} catch (error) {
console.log("Error Adding Todo: " + error)
}
}
export const getTodos = async ()=>{
try {
const response = await ApiService.get(`/getTodos`)
return response.data
} catch (error) {
console.log("Error fetching Todos: " + error)
}
}
export const markTodoAsCompleted = async (id: number)=>{
try {
const response = await ApiService.put(`/updateTodoStatus?id=${id}`)
return response.data
} catch (error) {
console.log("Error marking Todo as completed: " + error)
}
}