subject.api.js 951 Bytes
Newer Older
1
import axios from "axios";
Kim, Subin's avatar
Kim, Subin committed
2
import baseUrl from "../utils/baseUrl";
3

4
const addsubject = async (info, userId) => {
Kim, Subin's avatar
Kim, Subin committed
5
  const url = `${baseUrl}/api/subject/addsubject`;
6
7
8
9
  const { data } = await axios.post(url, { info, userId });
  return data
}

Choi Ga Young's avatar
Choi Ga Young committed
10
11
12
13
14
const allSubject = async (info) => {
  const url = `${baseUrl}/api/subject/all/${info}`
  const { data } = await axios.get(url);
  return data
}
15
const editSubject = async (info, id) => {
Choi Ga Young's avatar
Choi Ga Young committed
16
17
  const url = `${baseUrl}/api/subject/${id}`
  const { data } = await axios.put(url, info)
18
19
20
21
22
23
24
  return data
}

const getSubInfo = async (info) => {
  const url = `${baseUrl}/api/subject/${info}`
  const { data } = await axios.get(url);
  return data
25
}
Kim, Subin's avatar
Kim, Subin committed
26

Choi Ga Young's avatar
Choi Ga Young committed
27
28
29
30
31
32
33
const subjectTitle = async (info) => {
  const url = `${baseUrl}/api/subject/title/${info}`
  const { data } = await axios.get(url);
  return data
}


34
const subjectApi = {
35
36
  addsubject,
  getSubInfo,
Choi Ga Young's avatar
Choi Ga Young committed
37
38
39
  editSubject,
  allSubject,
  subjectTitle
40
41
42
};

export default subjectApi