mirror of
https://github.com/101island/lolisland.us.git
synced 2026-03-01 03:49:42 +08:00
21 lines
602 B
TypeScript
21 lines
602 B
TypeScript
// User data: Fetch user list from API and store
|
|
|
|
import { BACKEND_API_BASE } from "../config/loginApiBaseUrl";
|
|
import type { UserEntry } from "../config/marbleConfig";
|
|
|
|
export const USER_DATA_API = `${BACKEND_API_BASE}/users`;
|
|
|
|
// Fetch user data from API
|
|
export async function fetchUsers(): Promise<UserEntry[]> {
|
|
try {
|
|
const response = await fetch(USER_DATA_API);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to fetch users: ${response.statusText}`);
|
|
}
|
|
return await response.json();
|
|
} catch (error) {
|
|
console.error("Failed to fetch users:", error);
|
|
return [];
|
|
}
|
|
}
|