auth.api.js 695 Bytes
Newer Older
1
import axios from "axios";
Kim, Subin's avatar
Kim, Subin committed
2
import baseUrl from "../utils/baseUrl.js";
3

4
5
6
7
8
9
const getUser = async () => {
  const url = `${baseUrl}/api/auth/user`
  const { data } = await axios.get(url)
  return data
}

10
const signup = async (user) => {
Kim, Subin's avatar
Kim, Subin committed
11
  const url = `${baseUrl}/api/auth/signup`;
12
13
  const { data } = await axios.post(url, user);
  return data
14
15
16
}

const login = async (user) => {
Kim, Subin's avatar
Kim, Subin committed
17
  const url = `${baseUrl}/api/auth/login`;
18
19
20
21
22
23
24
25
  const { data } = await axios.post(url, user);
  return data
}

const logout = async () => {
  const url = `${baseUrl}/api/auth/logout`;
  const { data } = await axios.get(url);
  return data
26
27
28
}

const authApi = {
29
  getUser,
Kim, Subin's avatar
Kim, Subin committed
30
  signup,
31
32
  login,
  logout
33
34
35
};

export default authApi