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

CharacterHomeworld.vue

16 lines464 Bytes

1<script setup lang="ts">
2import { useQuery } from '@tanstack/vue-query'
3import { planetsQueries } from './services/planets/queries'
4​
5const props = defineProps<{ homeworldId: string }>()
6​
7const { data, status } = useQuery(() =>
8 planetsQueries.detail(props.homeworldId),
9)
10</script>
11​
12<template>
13 <span v-if="status === 'pending'">Loading...</span>
14 <span v-else-if="status === 'error'">Error :(</span>
15 <span v-else-if="data">{{ data.name }}</span>
16</template>