Open History to see the last commit
1---
2id: background-fetching-indicators
3title: Background Fetching Indicators
4ref: docs/framework/react/guides/background-fetching-indicators.md
5---
6β
7[//]: # 'Example'
8β
9```vue
10<script setup>
11import { useQuery } from '@tanstack/vue-query'
12β
13const { isPending, isFetching, isError, data, error } = useQuery({
14 queryKey: ['todos'],
15 queryFn: getTodos,
16})
17</script>
18β
19<template>
20 <div v-if="isFetching">Refreshing...</div>
21 <span v-if="isPending">Loading...</span>
22 <span v-else-if="isError">Error: {{ error.message }}</span>
23 <!-- We can assume by this point that `isSuccess === true` -->
24 <ul v-else-if="data">
25 <li v-for="todo in data" :key="todo.id">{{ todo.title }}</li>
26 </ul>
27</template>
28```
29β
30[//]: # 'Example'
31[//]: # 'Example2'
32β
33```vue
34<script setup>
35import { useIsFetching } from '@tanstack/vue-query'
36β
37const isFetching = useIsFetching()
38</script>
39β
40<template>
41 <div v-if="isFetching">Queries are fetching in the background...</div>
42</template>
43```
44β
45[//]: # 'Example2'