foo-vue-query.ts 282 B

123456789101112
  1. import { queryOptions } from '@tanstack/vue-query'
  2. import { getFooAPI } from './foo'
  3. export function getFooQueryOptions(name: string) {
  4. return queryOptions({
  5. queryFn: async ({ queryKey }) => {
  6. return getFooAPI(queryKey[1])
  7. },
  8. queryKey: ['getFoo', name],
  9. })
  10. }