answer.api.ts 897 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
import axios from "./axios.config";
2
import { IAnswer, IAnswerRequestData } from "../types";
3
4
import baseUrl from "./baseUrl";

5
6
7
8
9
10
11
12
13
14
15
/**
 * 파일을 제외한 json 형식의 답변 배열을 보내어 저장
 * @param answers IAnswer 배열
 * @returns 응답 배열?
 */
export const save = async (answers: IAnswerRequestData[]) => {
  const { data } = await axios.post(`${baseUrl}/answers`, answers);
  return data;
};

export const saveForm = async (answerForm: FormData) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
16
  console.log("formdata", answerForm);
17
18
19
20
  const { data } = await axios.post(`${baseUrl}/answers/upload`, answerForm);
  return data;
};

21
22
23
24
export const saveAnswers = async (answer: FormData) => {
  const { data } = await axios.post(`${baseUrl}/answers`, answer);
  return data;
};
Jiwon Yoon's avatar
Jiwon Yoon committed
25
26
27
28
29

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