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

Function defaultQueryFn

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected