MCPcopy Create free account
hub / github.com/TanStack/query / fetchState

Function fetchState

packages/query-core/src/query.ts:714–733  ·  view source on GitHub ↗
(
  data: TData | undefined,
  options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
)

Source from the content-addressed store, hash-verified

712}
713
714export function fetchState<
715 TQueryFnData,
716 TError,
717 TData,
718 TQueryKey extends QueryKey,
719>(
720 data: TData | undefined,
721 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
722) {
723 return {
724 fetchFailureCount: 0,
725 fetchFailureReason: null,
726 fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',
727 ...(data === undefined &&
728 ({
729 error: null,
730 status: 'pending',
731 } as const)),
732 } as const
733}
734
735function successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {
736 return {

Callers 2

createResultMethod · 0.90
reducerMethod · 0.85

Calls 1

canFetchFunction · 0.90

Tested by

no test coverage detected