/** * dbmsClient.ts * ------------- * Fetches DBMS topic data from the Go backend. */ const API_BASE = ''; export interface DBMSTopic { id: string; topic_no: number; topic_name: string; } export interface DBMSTopicContent extends DBMSTopic { content: string; } /** * Fetches all DBMS topics (topic_no and topic_name). */ export async function fetchDBMSTopics(): Promise { const res = await fetch(`${API_BASE}/api/dbms/topics`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }); if (!res.ok) { throw new Error(`API error ${res.status}: ${res.statusText}`); } const data = await res.json() as { topics: DBMSTopic[] }; return data.topics ?? []; } /** * Fetches full content for a specific DBMS topic. */ export async function fetchDBMSTopicContent(topicNo: number): Promise { const res = await fetch(`${API_BASE}/api/dbms/topics/${topicNo}`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }); if (!res.ok) { throw new Error(`API error ${res.status}: ${res.statusText}`); } return await res.json() as DBMSTopicContent; }