@openapi-qraft/react
Version:
OpenAPI client for React, providing type-safe requests and dynamic TanStack Query React Hooks via a modular, Proxy-based architecture.
12 lines (10 loc) • 469 B
text/typescript
import type { RequestFnResponse } from './requestFn.js';
export function requestFnResponseRejecter<TData, TError>(
requestFnResponseOrError: RequestFnResponse<TData, TError> | Error
): TData | undefined {
if (requestFnResponseOrError instanceof Error) throw requestFnResponseOrError;
if ('error' in requestFnResponseOrError) throw requestFnResponseOrError.error;
throw new Error('Unhandled `requestFn` response', {
cause: requestFnResponseOrError,
});
}