MCPcopy Index your code
hub / github.com/microsoft/data-formulator / apiRequest

Function apiRequest

src/app/apiClient.ts:152–176  ·  view source on GitHub ↗
(
    url: string,
    options?: RequestInit,
)

Source from the content-addressed store, hash-verified

150 * **Streaming endpoints should use {@link streamRequest} instead.**
151 */
152export async function apiRequest<T = any>(
153 url: string,
154 options?: RequestInit,
155): Promise<{ data: T }> {
156 const response = await fetchWithIdentity(url, options);
157
158 let body: any;
159 try {
160 body = await response.json();
161 } catch {
162 if (!response.ok) {
163 throw new ApiRequestError(
164 { code: 'HTTP_ERROR', message: `HTTP ${response.status}`, retry: false },
165 response.status,
166 );
167 }
168 throw new ApiRequestError(
169 { code: 'PARSE_ERROR', message: 'Invalid JSON response', retry: false },
170 response.status,
171 );
172 }
173
174 // parseApiResponse handles body-level success/error envelopes.
175 return parseApiResponse<T>(body, response.status);
176}
177
178/**
179 * Validate a file/blob download response without assuming JSON success bodies.

Callers 15

ConnectorTablePreviewFunction · 0.90
fetchDisplayRowsFunction · 0.90
autoSortFunctionFunction · 0.90
DataLoadMenuFunction · 0.90
AddConnectionPanelFunction · 0.90
UnifiedDataUploadDialogFunction · 0.90
DataSourceSidebarPanelFunction · 0.90
DataLoadingChatFunction · 0.90
testModelFunction · 0.90
testAndAssignModelFunction · 0.90

Calls 2

fetchWithIdentityFunction · 0.90
parseApiResponseFunction · 0.85

Tested by

no test coverage detected