Skip to content

Is My Approach to Using Pinia-Colada with a Pinia Store for Filters Correct? #156

Answered by posva
loic-bellinger asked this question in Questions
Discussion options

You must be logged in to vote

I would just adapt the store usage:

import { defineQuery } from '@pinia/colada';
import { useFiltersStore } from '@/stores/filters';
import { apiClient } from '@/api';

export const useNbPosts = defineQuery(() => {
  const filtersStore = useFiltersStore();
  return useQuery({
    key: () => ['nb_posts', filtersStore.apiPayload],
    query: () => apiClient.post('/v1/nb_post', filtersStore.apiPayload),
  })
});

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@loic-bellinger
Comment options

@posva
Comment options

@loic-bellinger
Comment options

@posva
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants