Add register function for $lib/api.ts

This commit is contained in:
qowevisa 2024-11-20 18:21:14 +02:00
parent 9104c0e274
commit 0b11141811

View File

@ -134,6 +134,13 @@ export async function login(username: string, password: string, cookies?: Cookie
}, cookies);
}
export async function register(username: string, password: string, cookies?: Cookies): Promise<LoginResponse> {
return apiFetch<LoginResponse>('/user/register', {
method: 'POST',
body: JSON.stringify({ username, password }),
}, cookies);
}
// Get user data function with type annotation for the response
export async function getUserData(token: string): Promise<UserData> {
return apiFetch<UserData>('/user/me', {