examples/vue/default-query-function
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Vue Query Default Query Function Example#
Sets a default queryFn on the QueryClient that builds the request URL from the query key, so each query only passes a queryKey.
How it works#
src/main.tsinstallsVueQueryPluginwith aqueryClientConfigwhosedefaultOptions.queries.queryFnfetcheshttps://jsonplaceholder.typicode.complusqueryKey[0].src/PostList.vuecallsuseQuerywith onlyqueryKey: ['/posts'], and shows a post in bold green whenqueryClient.getQueryData([`/posts/${post.id}`])returns data.src/PostDetail.vuepasses a getter touseQuerywithqueryKey: [`/posts/${props.postId}`]andenabled: !!props.postId, again without aqueryFn.
To run this example:
npm installnpm run dev