Open History to see the last commit
1<script setup lang="ts">
2import { Link } from '@tanstack/vue-router'
3import { useQuery } from '@tanstack/vue-query'
4import { moviesQueries } from '../services/movies/queries'
5β
6const { data, error, isError, isFetching, isLoading } = useQuery(
7 moviesQueries.list(),
8)
9</script>
10β
11<template>
12 <template v-if="isLoading">Loading...</template>
13 <div v-else-if="data">
14 <h1>Movies</h1>
15 <p>
16 Try to mock offline behavior with the button in the devtools. You can
17 navigate around as long as there is already data in the cache. You'll get
18 a refetch as soon as you go online again.
19 </p>
20 <ul>
21 <li v-for="movie in data.movies" :key="movie.id">
22 <Link to="/$movieId" :params="{ movieId: movie.id }">{{
23 movie.title
24 }}</Link>
25 </li>
26 </ul>
27 <div>Updated at: {{ new Date(data.ts).toLocaleTimeString() }}</div>
28 <div>{{ isFetching ? 'fetching...' : '' }}</div>
29 </div>
30 <div v-else-if="isError">
31 <h1>Couldn't load movies!</h1>
32 <div>{{ error?.message }}</div>
33 </div>
34</template>