Files
alibb-server/frontend/src/api/auth.ts
T

24 lines
588 B
TypeScript
Raw Normal View History

2026-08-27 16:11:49 +08:00
import request from '@/api/request'
/** Shape of a successful POST /api/auth/login response. */
export interface LoginResponse {
token: string
expiresIn: string
}
/**
* POST /api/auth/login with username + password.
* Throws a normalized {@link ApiError} (from the response interceptor) on
* failure — e.g. status 401 with message "invalid credentials".
*/
export async function loginApi(
username: string,
password: string,
): Promise<LoginResponse> {
const { data } = await request.post<LoginResponse>('/auth/login', {
username,
password,
})
return data
}