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

4
const getUser = async () => {
Kim, Subin's avatar
context    
Kim, Subin committed
5
  const url = `${baseUrl}/api/auth`
6
7
8
9
  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`;
Kim, Subin's avatar
context    
Kim, Subin committed
12
13
  const { data, status } = await axios.post(url, user);
  return { data, status }
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