Skip to content

Commit ccb17d6

Browse files
committed
feat: suspense
1 parent 7befb5e commit ccb17d6

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

app/components/modules/home/recent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
const { data } = useFetch('/api/post', {
2+
const { data } = await useFetch('/api/post', {
33
query: {
44
limit: '2',
55
},

app/pages/(home)/blog/[[page]].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const router = useRouter()
1313
const POSTS_LIMIT = 5
1414
const page = computed<number>(() => route.params.page ? Number.parseInt(route.params.page as string) : 1)
1515
16-
const { data: posts } = useFetch('/api/post', {
16+
const { data: posts } = await useFetch('/api/post', {
1717
query: {
1818
limit: POSTS_LIMIT,
1919
offset: (Math.max(1, page.value) - 1) * POSTS_LIMIT,

app/pages/(home)/blog/tag/[tag]/[[page]].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const router = useRouter()
1313
const POSTS_LIMIT = 5
1414
const page = computed<number>(() => route.params.page ? Number.parseInt(route.params.page as string) : 1)
1515
16-
const { data: posts } = useFetch(`/api/post/tag/${route.params.tag}`, {
16+
const { data: posts } = await useFetch(`/api/post/tag/${route.params.tag}`, {
1717
query: {
1818
limit: POSTS_LIMIT,
1919
offset: (Math.max(1, page.value) - 1) * POSTS_LIMIT,

app/pages/admin/(dashboard)/posts/[[page]].vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ const route = useRoute('admin-posts-page')
1818
1919
const page = computed<number>(() => route.params.page ? Number.parseInt(route.params.page as string) : 0)
2020
21-
const { data: posts, status, refresh } = useAsyncData(
22-
`admin-posts-page-${page.value}`,
23-
async () => {
24-
const response = await $fetch('/api/post', { query: { limit: 20, offset: (page.value - 1) * 20 } })
25-
return response
21+
const { data: posts, status, refresh } = await useFetch(
22+
'/api/post',
23+
{
24+
query: {
25+
limit: 20,
26+
offset: computed(() => (page.value - 1) * 20),
27+
},
2628
},
27-
{ watch: [page] },
2829
)
2930
3031
const { mutate: deletePost, isLoading: isDeleting } = useMutation({

0 commit comments

Comments
 (0)