auth.api.js 1.89 KB
Newer Older
한규민's avatar
한규민 committed
1
2
3
import axios from "axios";
import { baseUrl } from "../utils/baseUrl.js";

한규민's avatar
한규민 committed
4
5
6
7
8
9
const getUser = async () => {
  const url = `${baseUrl}/api/auth/user`
  const { data } = await axios.get(url)
  return data
}

한규민's avatar
한규민 committed
10
11
const login = async (login) => {
  const payload = login;
한규민's avatar
한규민 committed
12
13
14
15
16
  const { data } = await axios.post(`${baseUrl}/api/auth/login`, payload);
  return data
};

const logout = async () => {
한규민's avatar
한규민 committed
17
18
  const { data } = await axios.get(`${baseUrl}/api/auth/logout`);
  return data
한규민's avatar
한규민 committed
19
20
};

Jiwon Yoon's avatar
Jiwon Yoon committed
21
22
23
24
25
const saveGuestInfo = async (guest) => {
  const { data } = await axios.post(`${baseUrl}/api/auth/guest/save`, guest);
  return data
}

한규민's avatar
한규민 committed
26
27
28
29
30
const guestLogin = async (guest) => {
  const { data } = await axios.post(`${baseUrl}/api/auth/guest`, guest);
  return data
}

한규민's avatar
한규민 committed
31
const signup = async (user) => {
한규민's avatar
한규민 committed
32
33
34
  const url = `${baseUrl}/api/auth/signup`;
  const { data } = await axios.post(url, user);
  return data
한규민's avatar
한규민 committed
35
36
}

한규민's avatar
한규민 committed
37
38
const confirmMbnum = async (phone) => {
  const url = `${baseUrl}/api/auth/phone/${phone}`
39
  const { data } = await axios.post(url);
한규민's avatar
한규민 committed
40
41
42
  return data
}

43
44
45
const confirmNum = async (confirmNum) => {
  const url = `${baseUrl}/api/auth/num`
  const { data } = await axios.post(url, confirmNum);
한규민's avatar
한규민 committed
46
47
48
  return data
}

한규민's avatar
한규민 committed
49
50
51
52
53
const profile = async (formData) => {
  const url = `${baseUrl}/api/auth/profile`
  const { data } = await axios.post(url, formData)
  return data
}
한규민's avatar
한규민 committed
54
const getMember = async () => {
한규민's avatar
한규민 committed
55
  const url = `${baseUrl}/api/auth/member`
한규민's avatar
한규민 committed
56
57
58
59
60
61
62
  const { data } = await axios.get(url)
  return data
}

const comparePw = async (pw) => {
  const url = `${baseUrl}/api/auth/pw/${pw}`
  const { data } = await axios.get(url)
한규민's avatar
한규민 committed
63
64
65
66
67
  return data
}

const modifyUser = async (user) => {
  const url = `${baseUrl}/api/auth/modify`
68
69
  const { data } = await axios.post(url, user)
  return data
한규민's avatar
한규민 committed
70
71
}

한규민's avatar
한규민 committed
72
const authApi = {
한규민's avatar
한규민 committed
73
  getUser,
한규민's avatar
한규민 committed
74
75
  login,
  logout,
Jiwon Yoon's avatar
Jiwon Yoon committed
76
  saveGuestInfo,
한규민's avatar
한규민 committed
77
  guestLogin,
한규민's avatar
한규민 committed
78
  signup,
한규민's avatar
한규민 committed
79
  confirmMbnum,
한규민's avatar
한규민 committed
80
  confirmNum,
한규민's avatar
한규민 committed
81
82
  profile,
  getMember,
한규민's avatar
한규민 committed
83
  comparePw,
한규민's avatar
한규민 committed
84
  modifyUser
한규민's avatar
한규민 committed
85
86
};
export default authApi