auth.api.js 1.74 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
};

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

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

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

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

한규민's avatar
한규민 committed
44
45
46
47
48
const profile = async (formData) => {
  const url = `${baseUrl}/api/auth/profile`
  const { data } = await axios.post(url, formData)
  return data
}
한규민's avatar
한규민 committed
49
const getMember = async () => {
한규민's avatar
한규민 committed
50
  const url = `${baseUrl}/api/auth/member`
한규민's avatar
한규민 committed
51
52
53
54
55
56
57
  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
58
59
60
61
62
  return data
}

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

한규민's avatar
한규민 committed
67
const authApi = {
한규민's avatar
한규민 committed
68
  getUser,
한규민's avatar
한규민 committed
69
70
  login,
  logout,
한규민's avatar
한규민 committed
71
  guestLogin,
한규민's avatar
한규민 committed
72
  signup,
한규민's avatar
한규민 committed
73
  confirmMbnum,
한규민's avatar
한규민 committed
74
  confirmNum,
한규민's avatar
한규민 committed
75
76
  profile,
  getMember,
한규민's avatar
한규민 committed
77
  comparePw,
한규민's avatar
한규민 committed
78
  modifyUser
한규민's avatar
한규민 committed
79
80
};
export default authApi