survey.api.ts 1.15 KB
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
export const createSurvey = async (survey: SurveyType) => {
  const { data } = await axios.post(`${baseUrl}/surveys/create`, survey);
  return data;
};

export const getSurvey = async (surveyId: string) => {
jang dong hyeok's avatar
jang dong hyeok committed
11
  const { data } = await axios.get(`${baseUrl}/surveys/${surveyId}/edit`);
Jiwon Yoon's avatar
Jiwon Yoon committed
12
13
  return data;
};
14
<<<<<<< HEAD
Jiwon Yoon's avatar
Jiwon Yoon committed
15
export const getASurvey = async (surveyId: string) => {
jang dong hyeok's avatar
jang dong hyeok committed
16
  const { data } = await axios.get(`${baseUrl}/surveys/${surveyId}/edit`);
17
=======
18
19

export const ansSurvey = async (surveyId: string) => {
20
  const { data } = await axios.get(`${baseUrl}/surveys/${surveyId}`);
21
>>>>>>> develop0718
Jiwon Yoon's avatar
Jiwon Yoon committed
22
23
  return data;
};
24

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

export const editSurvey = async (survey: SurveyType) => {
  const { data } = await axios.put(
jang dong hyeok's avatar
jang dong hyeok committed
33
    `${baseUrl}/surveys/${survey._id}/edit`,
Jiwon Yoon's avatar
Jiwon Yoon committed
34
35
36
37
    survey
  );
  return data;
};
38
39

export const deleteSurvey = async (surveyId: string) => {
jang dong hyeok's avatar
jang dong hyeok committed
40
  const { data } = await axios.delete(`${baseUrl}/surveys/${surveyId}/delete`);
41
42
  return data;
};