defineQuery in composables with parameters #100
Unanswered
niklaswolf
asked this question in
Questions
Replies: 1 comment 2 replies
-
In this case of scenario, the // composable to group all functionality for a single todo
const useTodo = defineQuery(() => {
const id = ref('my-id')
const query = useQuery({
key: () => ['todo', id.value],
query: () => {
return fetch(`/api/todos/${id}`)
},
})
// other function regarding a todo, e.g. a mutation
const otherFunction = () => {}
return { ...query, otherFunction, id }
}) This makes |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it necessary to use
defineQuery
in the following case, or is it sufficiant to useuseQuery
?How would I use
defineQuery
in such a case, because the setup function doesn't allow for parameters.The
useTodo
composable would be reused in multiple places.Beta Was this translation helpful? Give feedback.
All reactions