@polargold/pg-frontend-vue
    Preparing search index...

    Interface UseApiOptions<ReturnValue, Parameters>

    interface UseApiOptions<ReturnValue, Parameters> {
        callback: (
            parameters?: Parameters,
        ) => ReturnValue | Promise<ReturnValue>;
        onError?: (errors?: unknown) => void;
        onFinally?: () => void;
        onSuccess?: (data?: ReturnValue) => void;
        rethrow?: boolean;
    }

    Type Parameters

    • ReturnValue
    • Parameters
    Index
    callback: (parameters?: Parameters) => ReturnValue | Promise<ReturnValue>

    May return ReturnValue directly or a Promise<ReturnValue> - ReturnValue itself is always the resolved data type (what onSuccess/apiData actually receive), not whatever the callback's own return type literally is. Passing an async callback with no explicit useApi<T> type argument previously made ReturnValue infer as Promise<T> instead of T, which type-checked fine inside a loosely-typed callback but broke the moment onSuccess/apiData were used against a real, concretely-typed domain object.

    onError?: (errors?: unknown) => void
    onFinally?: () => void
    onSuccess?: (data?: ReturnValue) => void
    rethrow?: boolean

    Whether callApi() rethrows a failed call (as an ApiCallError) after onError runs. Defaults to true - the original contract. Set to false when onError already fully owns error feedback (e.g. it sets a reactive hasError/shows a UI error state) and every call site would otherwise need its own no-op .catch() just to avoid an unhandled rejection - a real, duplicated pattern found across luv-autoq-frontend's Pinia stores.