Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

queries.ts

16 lines451 Bytes

1import { queryOptions } from '@tanstack/vue-query'
2import { postsAPI } from './api'
3​
4export const postsQueries = {
5 all: () => ['posts'] as const,
6 list: () =>
7 queryOptions({
8 queryKey: [...postsQueries.all(), 'list'] as const,
9 queryFn: () => postsAPI.getPosts(),
10 }),
11 detail: (id: number) =>
12 queryOptions({
13 queryKey: [...postsQueries.all(), 'detail', id] as const,
14 queryFn: () => postsAPI.getPost(id),
15 }),