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

한규민's avatar
한규민 committed
5
6
const login = async (login) => {
  const payload = login;
한규민's avatar
한규민 committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  const { data } = await axios.post(`${baseUrl}/api/auth/login`, payload);
  return data
};

const logout = async () => {
  alert("로그아웃되었습니다.");
  localStorage.removeItem(config.loginUser);
  await axios.get(`${baseUrl}/api/auth/logout`);
};

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
28
29
30
31
32
33
const confirmMbnum = async (id,token) => {
  const url = `${baseUrl}/api/auth/${id}/${token}`
  const { data } = await axios.get(url)
  return data
}

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

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

한규민's avatar
한규민 committed
45
46
47
48
49
const authApi = {
  login,
  logout,
  signup,
  compareId,
한규민's avatar
한규민 committed
50
51
  confirmMbnum,
  getNickName,
한규민's avatar
한규민 committed
52
  modifyUser,
한규민's avatar
한규민 committed
53
54
};
export default authApi