aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/api/User.ts
blob: 004aa22fbda67df5b925ab7e4f1aa70297381bc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import axios from "axios";
import { url } from "@api/Api";
import { UserProfile } from "@customTypes/Profile";

export const get_user = async (user_id: string): Promise<UserProfile> => {
  const response = await axios.get(url(`users/${user_id}`));
  return response.data.data;
};

export const get_profile = async (token: string): Promise<UserProfile> => {
  const response = await axios.get(url(`profile`), {
    headers: {
      Authorization: token,
    },
  });
  return response.data.data;
};

export const post_profile = async (token: string): Promise<void> => {
  await axios.post(
    url(`profile`),
    {},
    {
      headers: {
        Authorization: token,
      },
    }
  );
};