plan.api.js 857 Bytes
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
2
3
import axios from "axios";
import baseUrl from "../utils/baseUrl";

Kim, Subin's avatar
Kim, Subin committed
4
5
6
7
8
9
const getDetail = async (id) => {
  const url = `${baseUrl}/api/plan/getDetail/${id}`
  const { data } = await axios.get(url)
  return data
}

Choi Ga Young's avatar
Choi Ga Young committed
10
11
12
13
14
15
16
17
18
19
const addPlan = async (info, id) => {
  console.log('addPlan 확인', id)
  const url = `${baseUrl}/api/plan/addplan/${id}`
  const { data } = await axios.post(url, { info, id });
  return data
}

const editPlan = async (info, id) => {
  console.log('editPlan확인', id)
  const url = `${baseUrl}/api/plan/edit/${id}`
Choi Ga Young's avatar
Choi Ga Young committed
20
  const { data } = await axios.put(url, { info, id });
Choi Ga Young's avatar
Choi Ga Young committed
21
22
23
  return data
}

Kim, Subin's avatar
Kim, Subin committed
24
25
26
const remove = async (planId, userId) => {
  const url = `${baseUrl}/api/plan/${planId}?userId=${userId}`
  const { data } = await axios.delete(url)
Choi Ga Young's avatar
Choi Ga Young committed
27
28
  return data
}
Kim, Subin's avatar
Kim, Subin committed
29

Choi Ga Young's avatar
Choi Ga Young committed
30
const planApi = {
Kim, Subin's avatar
Kim, Subin committed
31
  getDetail,
Choi Ga Young's avatar
Choi Ga Young committed
32
33
  addPlan,
  editPlan,
Kim, Subin's avatar
Kim, Subin committed
34
  remove
Choi Ga Young's avatar
Choi Ga Young committed
35
36
37
};

export default planApi