auth.api.js 1.57 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
10
const getUser = async () => {
  const url = `${baseUrl}/api/auth/user`
  const { data } = await axios.get(url)
  return data

}

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

const logout = async () => {
  alert("로그아웃되었습니다.");
한규민's avatar
한규민 committed
19
20
  const { data } = await axios.get(`${baseUrl}/api/auth/logout`);
  return data
한규민's avatar
한규민 committed
21
22
23
24
25
26
27
28
29
30
31
};

const signup = async (user) => {
  const url = `${baseUrl}/api/auth/signup`
  await axios.post(url, user)
}

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

한규민's avatar
한규민 committed
34
const confirmMbnum = async (id, token) => {
한규민's avatar
한규민 committed
35
36
37
38
39
  const url = `${baseUrl}/api/auth/${id}/${token}`
  const { data } = await axios.get(url)
  return data
}

한규민's avatar
한규민 committed
40
41
42
43
44
45
46
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
47
48
49
50
51
52
53
  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
54
55
56
57
58
59
  return data
}

const modifyUser = async (user) => {
  const url = `${baseUrl}/api/auth/modify`
  await axios.post(url, user)
한규민's avatar
한규민 committed
60
61
}

한규민's avatar
한규민 committed
62
const authApi = {
한규민's avatar
한규민 committed
63
  getUser,
한규민's avatar
한규민 committed
64
65
66
67
  login,
  logout,
  signup,
  compareId,
한규민's avatar
한규민 committed
68
  confirmMbnum,
한규민's avatar
한규민 committed
69
70
  profile,
  getMember,
한규민's avatar
한규민 committed
71
  comparePw,
한규민's avatar
한규민 committed
72
  modifyUser,
한규민's avatar
한규민 committed
73
74
};
export default authApi