Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

478 B
Raw Blame
import type { ApiClient } from '../client';

export interface Credentials {
  username: string;
  password: string;
}

export async function login(api: ApiClient, { username, password }: Credentials) {
  const response = await api.post('/api/auth/login', { username, password });

  if (response.status !== 200 || !response.body?.token) {
    throw new Error(`Login failed for ${username} (${response.status}): ${response.text}`);
  }

  return response.body.token as string;
}