todo.api.js 777 Bytes
Newer Older
Kim, Subin's avatar
Kim, Subin committed
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
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
}

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,
    submit,
    edit,
    remove
}

export default todoApi