survey.api.ts 1001 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
import axios from "axios";
import { SurveyType } from "../types";
import baseUrl from "./baseUrl";

Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
7
8
9
10
11
12
13
export const createSurvey = async (survey: SurveyType) => {
  const { data } = await axios.post(`${baseUrl}/surveys/create`, survey);
  return data;
};

export const getSurvey = async (surveyId: string) => {
  const { data } = await axios.get(`${baseUrl}/surveys/edit/${surveyId}`);
  return data;
};
14
15
16
17
18
19

export const ansSurvey = async (surveyId: string) => {
  const { data} = await axios.get(`${baseUrl}/surveys/${surveyId}`);
  return data;
}

20
21
22
23
24
//동혁
export const getSurveys = async () => {
  const { data } = await axios.get(`${baseUrl}/surveys/`);
  return data;
};
Jiwon Yoon's avatar
Jiwon Yoon committed
25
26
27
28
29
30
31
32

export const editSurvey = async (survey: SurveyType) => {
  const { data } = await axios.put(
    `${baseUrl}/surveys/edit/${survey._id}`,
    survey
  );
  return data;
};
33
34
35
36
37

export const deleteSurvey = async (surveyId: string) => {
  const { data } = await axios.delete(`${baseUrl}/surveys/delete/${surveyId}`);
  return data;
};