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

Function defaultQueryFn

examples/solid/default-query-function/src/index.tsx:20–29  ·  view source on GitHub ↗
({ queryKey })

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected