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

Function parseJsonResponse

frontend/src/api/sources.ts:6–14  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

4const API_BASE = '/api';
5
6async function parseJsonResponse<T>(response: Response): Promise<T> {
7 const contentType = response.headers.get('content-type');
8 if (contentType && contentType.includes('application/json')) {
9 return response.json();
10 }
11 // Fallback to text if not JSON
12 const text = await response.text();
13 throw new ApiError(text || response.statusText, response.status, response.statusText);
14}
15
16export async function fetchSources(): Promise<DataSource[]> {
17 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected