| |
| |
| |
| |
| |
|
|
| const API_BASE = ''; |
|
|
| export interface DBMSTopic { |
| id: string; |
| topic_no: number; |
| topic_name: string; |
| } |
|
|
| export interface DBMSTopicContent extends DBMSTopic { |
| content: string; |
| } |
|
|
| |
| |
| |
| export async function fetchDBMSTopics(): Promise<DBMSTopic[]> { |
| 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 ?? []; |
| } |
|
|
| |
| |
| |
| export async function fetchDBMSTopicContent(topicNo: number): Promise<DBMSTopicContent> { |
| 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; |
| } |
|
|