auth.api.ts 747 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
import axios from "axios";
Yoon, Daeki's avatar
Yoon, Daeki committed
2
import { SignupUser } from "../types";
Yoon, Daeki's avatar
Yoon, Daeki committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import baseUrl from "./baseUrl";

export const login = async (email: string, password: string) => {
  const { data } = await axios.post(`${baseUrl}/auth/login`, {
    email,
    password,
  });
  return data;
};

export const logout = async () => {
  const { data } = await axios.get(`${baseUrl}/auth/logout`);
  return data;
};
Yoon, Daeki's avatar
Yoon, Daeki committed
17
18
19
20
21

export const signup = async (user: SignupUser) => {
  const { data } = await axios.post(`${baseUrl}/auth/signup`, user);
  return data;
};
22
23
24
25
26
27
28
29

export const getKakaoUserData = async (code: string) => {
  const { data } = await axios.post(`${baseUrl}/auth/oauth/kakao`, {
    code: code,
  });
  console.log("data=", data);
  return data.kakaoUserData;
};