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

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

const compareId = async (userId) => {
  const url = `${baseUrl}/api/auth/${userId}`
  const { data } = await axios.get(url)
  return data
한규민's avatar
한규민 committed
31
}
한규민's avatar
한규민 committed
32

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

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

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

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

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