Skip to content

How does one stitch together two or more states from useQuery? #150

Answered by mmulich
mmulich asked this question in Questions
Discussion options

You must be logged in to vote

Well, sometimes you need only ask the question to find the answer yourself.
The following works because it's now using a reactive property data (a shallow ref) as opposed to the computed state property.

Though, I wonder if there is a more elegant solution I'm not seeing?

<script setup>
// ... imports and other common stuff ...

const { data: todo, status: todoStatus } = useQuery({
  key: () => ["todo", route.params.id],
  query: () => getTodo(route.params.id),
});
const { data: allTags, status: allTagsStatus } = useQuery({
  key: ["tags"],
  query: getAllTags,
});

// Attempt to monitor the loading state in a unified property
const isLoading = computed(
  () => !(allTagsStatus.value === "s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@posva
Comment options

posva Jan 2, 2025
Maintainer

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