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

Function defaultQueryFn

examples/react/default-query-function/src/index.tsx:19–25  ·  view source on GitHub ↗
({ queryKey }: { queryKey: QueryKey })

Source from the content-addressed store, hash-verified

17
18// Define a default query function that will receive the query key
19const defaultQueryFn = async ({ queryKey }: { queryKey: QueryKey }) => {
20 const response = await fetch(
21 `https://jsonplaceholder.typicode.com${queryKey[0]}`,
22 )
23 if (!response.ok) throw new Error('Failed to fetch data')
24 return await response.json()
25}
26
27// provide the default query function to your app via the query client
28const queryClient = new QueryClient({

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected