| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { get } from "../config/request";
- import axiosAPI from "../config/axios";
- export const login = async (username, password) => {
- try {
- const data = {
- username,
- password,
- };
- const response = await axiosAPI.post("/login", data, {
- headers: {
- "Content-Type": "application/json",
- },
- });
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const refreshToken = async () => {
- try {
- const response = await axiosAPI.get("/token");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const getUser = async () => {
- try {
- const response = await get("/user");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const logout = async () => {
- try {
- const response = await axiosAPI.delete("/logout");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
|