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

Function fetchRequests

frontend/src/api/requests.ts:6–29  ·  view source on GitHub ↗
(sourceId?: string)

Source from the content-addressed store, hash-verified

4const API_BASE = '/api';
5
6export async function fetchRequests(sourceId?: string): Promise<RequestsResponse> {
7 try {
8 const url = sourceId
9 ? `${API_BASE}/requests?source_id=${encodeURIComponent(sourceId)}`
10 : `${API_BASE}/requests`;
11
12 const response = await fetch(url);
13
14 if (!response.ok) {
15 const errorMessage = await response
16 .json()
17 .then((data) => data.error)
18 .catch(() => response.statusText);
19 throw new ApiError(`Failed to fetch requests: ${errorMessage}`, response.status, response.statusText);
20 }
21
22 return response.json();
23 } catch (err) {
24 if (err instanceof ApiError) {
25 throw err;
26 }
27 throw new ApiError(err instanceof Error ? err.message : 'Network error', 0);
28 }
29}

Callers 1

RequestViewFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected