auth.api.js 1.6 KB
Newer Older
한규민's avatar
한규민 committed
1
2
import axios from "axios";
import { baseUrl } from "../utils/baseUrl.js";
Kim, Subin's avatar
Kim, Subin committed
3
4
5
6
7
8

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

한규민'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 () => {
Kim, Subin's avatar
Kim, Subin committed
17
18
  const { data } = await axios.get(`${baseUrl}/api/auth/logout`);
  return data
한규민's avatar
한규민 committed
19
20
21
};

const signup = async (user) => {
Kim, Subin's avatar
Kim, Subin committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  const url = `${baseUrl}/api/auth/signup`;
  const { data } = await axios.post(url, user);
  return data
}

const confirmMbnum = async (phone) => {
  const url = `${baseUrl}/api/auth/phone/${phone}`
  const { data } = await axios.post(url);
  return data
}

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

Kim, Subin's avatar
Kim, Subin committed
39
40
41
42
43
44
45
const profile = async (formData) => {
  const url = `${baseUrl}/api/auth/profile`
  const { data } = await axios.post(url, formData)
  return data
}
const getMember = async () => {
  const url = `${baseUrl}/api/auth/member`
한규민's avatar
한규민 committed
46
47
  const { data } = await axios.get(url)
  return data
Kim, Subin's avatar
Kim, Subin committed
48
}
한규민's avatar
한규민 committed
49

Kim, Subin's avatar
Kim, Subin committed
50
51
const comparePw = async (pw) => {
  const url = `${baseUrl}/api/auth/pw/${pw}`
한규민's avatar
한규민 committed
52
53
54
55
  const { data } = await axios.get(url)
  return data
}

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

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