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

queries.ts

14 lines450 Bytes

1import { queryOptions } from '@tanstack/svelte-query'
2import { api } from './api'
3​
4export const postsQueryOptions = (limit: number, customFetch?: typeof fetch) =>
5 queryOptions({
6 queryKey: ['posts', limit],
7 queryFn: () => api(customFetch).getPosts(limit),
8 })
9​
10export const postQueryOptions = (id: number, customFetch?: typeof fetch) =>
11 queryOptions({
12 queryKey: ['post', id],
13 queryFn: () => api(customFetch).getPostById(id),
14 })