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

Function fetchState

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

Source from the content-addressed store, hash-verified

905}
906
907export function fetchState<
908 TQueryFnData,
909 TError,
910 TData,
911 TQueryKey extends QueryKey,
912>(
913 data: TData | undefined,
914 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
915) {
916 return {
917 fetchFailureCount: 0,
918 fetchFailureReason: null,
919 fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',
920 ...(data === undefined &&
921 ({
922 error: null,
923 status: 'pending',
924 } as const)),
925 } as const
926}
927
928function successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {
929 return {

Callers 2

createResultMethod · 0.90
reducerMethod · 0.85

Calls 1

canFetchFunction · 0.90

Tested by

no test coverage detected