plan.api.js 715 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
plan    
Kim, Subin committed
4
5
const getDetail = async (planId) => {
  const url = `${baseUrl}/api/plan/${planId}`
Kim, Subin's avatar
Kim, Subin committed
6
7
8
9
  const { data } = await axios.get(url)
  return data
}

Kim, Subin's avatar
plan    
Kim, Subin committed
10
11
12
const submit = async (info) => {
  const url = `${baseUrl}/api/plan`
  const { data } = await axios.post(url, info)
Choi Ga Young's avatar
Choi Ga Young committed
13
14
15
  return data
}

Kim, Subin's avatar
plan    
Kim, Subin committed
16
17
18
const edit = async (info, planId) => {
  const url = `${baseUrl}/api/plan/${planId}`
  const { data } = await axios.put(url, info)
Choi Ga Young's avatar
Choi Ga Young committed
19
20
21
  return data
}

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

Choi Ga Young's avatar
Choi Ga Young committed
28
const planApi = {
Kim, Subin's avatar
Kim, Subin committed
29
  getDetail,
Kim, Subin's avatar
plan    
Kim, Subin committed
30
31
  submit,
  edit,
Kim, Subin's avatar
Kim, Subin committed
32
  remove
Choi Ga Young's avatar
Choi Ga Young committed
33
34
35
};

export default planApi