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

Method fetch

packages/query-core/src/queryObserver.ts:471–481  ·  view source on GitHub ↗

* Fetches the observed query and updates the result once the fetch settles. Used by `refetch` and, * in `InfiniteQueryObserver`, to fetch more pages. * @param fetchOptions - Options for this fetch. `cancelRefetch` defaults to `true`. * @returns A promise that resolves with the updated resul

(
    fetchOptions: ObserverFetchOptions,
  )

Source from the content-addressed store, hash-verified

469 * @returns A promise that resolves with the updated result.
470 */
471 protected fetch(
472 fetchOptions: ObserverFetchOptions,
473 ): Promise<QueryObserverResult<TData, TError>> {
474 return this.#executeFetch({
475 ...fetchOptions,
476 cancelRefetch: fetchOptions.cancelRefetch ?? true,
477 }).then(() => {
478 this.updateResult()
479 return this.#currentResult
480 })
481 }
482
483 #executeFetch(
484 fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,

Callers 3

refetchMethod · 0.95
fetchOptimisticMethod · 0.45
#executeFetchMethod · 0.45

Calls 2

#executeFetchMethod · 0.95
updateResultMethod · 0.95

Tested by

no test coverage detected