MCPcopy
hub / github.com/jamiepine/voicebox / request

Function request

app/src/lib/api/core/request.ts:309–341  ·  view source on GitHub ↗
(
  config: OpenAPIConfig,
  options: ApiRequestOptions,
)

Source from the content-addressed store, hash-verified

307 * @throws ApiError
308 */
309export const request = <T>(
310 config: OpenAPIConfig,
311 options: ApiRequestOptions,
312): CancelablePromise<T> => {
313 return new CancelablePromise(async (resolve, reject, onCancel) => {
314 try {
315 const url = getUrl(config, options);
316 const formData = getFormData(options);
317 const body = getRequestBody(options);
318 const headers = await getHeaders(config, options);
319
320 if (!onCancel.isCancelled) {
321 const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
322 const responseBody = await getResponseBody(response);
323 const responseHeader = getResponseHeader(response, options.responseHeader);
324
325 const result: ApiResult = {
326 url,
327 ok: response.ok,
328 status: response.status,
329 statusText: response.statusText,
330 body: responseHeader ?? responseBody,
331 };
332
333 catchErrorCodes(options, result);
334
335 resolve(result.body);
336 }
337 } catch (error) {
338 reject(error);
339 }
340 });
341};

Callers

nothing calls this directly

Calls 9

getUrlFunction · 0.85
getFormDataFunction · 0.85
getRequestBodyFunction · 0.85
getHeadersFunction · 0.85
sendRequestFunction · 0.85
getResponseBodyFunction · 0.85
getResponseHeaderFunction · 0.85
catchErrorCodesFunction · 0.85
resolveFunction · 0.85

Tested by

no test coverage detected