todo.api.js 980 Bytes
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
2
3
4
5
6
7
8
import axios from "axios";
import baseUrl from "../utils/baseUrl";

const getTodo = async (userId, date = "", todoId = "") => {
    const { data } = await axios.get(`${baseUrl}/api/todo/${userId}?todoId=${todoId}&date=${date}`)
    return data
}

Kim, Subin's avatar
Kim, Subin committed
9
10
11
12
13
const getTodopercent = async (userId, start, end = "") => {
    const { data } = await axios.get(`${baseUrl}/api/todo/percent/${userId}?start=${start}&end=${end}`)
    return data
}

Kim, Subin's avatar
Kim, Subin committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const submit = async (todo, userId) => {
    const { data } = await axios.post(`${baseUrl}/api/todo/${userId}`, todo)
    return data
}

const edit = async (todo, userId) => {
    const { data } = await axios.put(`${baseUrl}/api/todo/${userId}?todoId=${todo.id}`, todo)
    return data
}

const remove = async (todoId, userId) => {
    const { data } = await axios.delete(`${baseUrl}/api/todo/${userId}?todoId=${todoId}`)
    return data
}

const todoApi = {
    getTodo,
Kim, Subin's avatar
Kim, Subin committed
31
    getTodopercent,
Kim, Subin's avatar
Kim, Subin committed
32
33
34
35
36
37
    submit,
    edit,
    remove
}

export default todoApi