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

Function defaultQueryFn

examples/lit/default-query-function/src/main.ts:8–14  ·  view source on GitHub ↗
({ queryKey }: { queryKey: QueryKey })

Source from the content-addressed store, hash-verified

6
7// Define a default query function that will receive the query key
8const defaultQueryFn = async ({ queryKey }: { queryKey: QueryKey }) => {
9 const response = await fetch(
10 `https://jsonplaceholder.typicode.com${queryKey[0]}`,
11 )
12 if (!response.ok) throw new Error('Failed to fetch data')
13 return await response.json()
14}
15
16// provide the default query function to your app with defaultOptions
17const queryClient = new QueryClient({

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected