llm-router / apps /web /src /api /auth.ts
ClaraSu's picture
Upload folder using huggingface_hub
b207060 verified
Raw History Blame Contribute Delete
977 Bytes
import { apiFetch } from './client'
export async function login(email: string, password: string): Promise<{ token: string }> {
const res = await apiFetch('/auth/login', {
method: 'POST',
body: JSON.stringify({ email, password }),
})
if (!res.ok) {
const err = await res.json() as { error?: string }
throw new Error(err.error ?? 'Login failed')
}
return res.json() as Promise<{ token: string }>
}
export async function signup(
email: string,
password: string,
tenantName?: string,
country?: string,
): Promise<{ token: string }> {
const res = await apiFetch('/auth/signup', {
method: 'POST',
body: JSON.stringify({
email,
password,
...(tenantName ? { tenant_name: tenantName } : {}),
...(country ? { country } : {}),
}),
})
if (!res.ok) {
const err = await res.json() as { error?: string }
throw new Error(err.error ?? 'Signup failed')
}
return res.json() as Promise<{ token: string }>
}