library-picturebook-activity/frontend/src/api/auth.ts

24 lines
729 B
TypeScript
Raw Normal View History

2025-11-23 14:04:20 +08:00
import request from "@/utils/request";
import type { LoginForm, LoginResponse, User } from "@/types/auth";
export const authApi = {
login: async (data: LoginForm): Promise<LoginResponse> => {
const response = await request.post("/auth/login", data);
2026-01-18 17:58:38 +08:00
return response as unknown as LoginResponse;
2025-11-23 14:04:20 +08:00
},
logout: async (): Promise<void> => {
await request.post("/auth/logout");
},
getUserInfo: async (): Promise<User> => {
const response = await request.get("/auth/user-info");
2026-01-18 17:58:38 +08:00
return response as unknown as User;
2025-11-23 14:04:20 +08:00
},
refreshToken: async (): Promise<{ token: string }> => {
const response = await request.post("/auth/refresh-token");
2026-01-18 17:58:38 +08:00
return response as unknown as { token: string };
2025-11-23 14:04:20 +08:00
},
};