MCPcopy Create free account
hub / github.com/bytebase/dbhub / fetchSources

Function fetchSources

frontend/src/api/sources.ts:16–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14}
15
16export async function fetchSources(): Promise<DataSource[]> {
17 try {
18 const response = await fetch(`${API_BASE}/sources`);
19
20 if (!response.ok) {
21 const errorMessage = await parseJsonResponse<{ error: string }>(response)
22 .then((data) => data.error)
23 .catch(() => response.statusText);
24 throw new ApiError(`Failed to fetch sources: ${errorMessage}`, response.status, response.statusText);
25 }
26
27 return response.json();
28 } catch (err) {
29 // Ensure all errors are ApiError instances
30 if (err instanceof ApiError) {
31 throw err;
32 }
33 // Network errors, timeout, etc.
34 throw new ApiError(err instanceof Error ? err.message : 'Network error', 0);
35 }
36}
37
38export async function fetchSource(sourceId: string): Promise<DataSource> {
39 try {

Callers 3

AppFunction · 0.90
RequestViewFunction · 0.90
HomeRedirectFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected