auth.api.ts 1.03 KB
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;
};
Jiwon Yoon's avatar
Jiwon Yoon committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

export const saveOauthKeys = async (
  socialType: string,
  REST_API_KEY: string,
  REDIRECT_URI: string,
  CLIENT_SECRET_KEY: string
) => {
  const { data } = await axios.post(`${baseUrl}/auth/oauth`, {
    socialType,
    REST_API_KEY,
    REDIRECT_URI,
    CLIENT_SECRET_KEY,
  });
  return data;
};