auto-sync: 2026-05-17 06:36:16
This commit is contained in:
@@ -24,7 +24,14 @@ async function fetchJSON<T>(url: string, options?: RequestInit): Promise<T> {
|
|||||||
// ---- Projects ----
|
// ---- Projects ----
|
||||||
|
|
||||||
export async function listProjects(): Promise<Project[]> {
|
export async function listProjects(): Promise<Project[]> {
|
||||||
return fetchJSON('/projects');
|
const data = await fetchJSON<unknown>('/projects');
|
||||||
|
if (Array.isArray(data)) return data as Project[];
|
||||||
|
if (data && typeof data === 'object') {
|
||||||
|
const obj = data as Record<string, unknown>;
|
||||||
|
const projectsObj = ('projects' in obj ? obj.projects : obj) as Record<string, Project>;
|
||||||
|
return Object.values(projectsObj);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProject(projectId: string): Promise<Project> {
|
export async function getProject(projectId: string): Promise<Project> {
|
||||||
|
|||||||
Reference in New Issue
Block a user