File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- const { data } = useFetch (' /api/post' , {
2+ const { data } = await useFetch (' /api/post' , {
33 query: {
44 limit: ' 2' ,
55 },
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const router = useRouter()
1313const POSTS_LIMIT = 5
1414const 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 ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const router = useRouter()
1313const POSTS_LIMIT = 5
1414const 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 ,
Original file line number Diff line number Diff line change @@ -18,13 +18,14 @@ const route = useRoute('admin-posts-page')
1818
1919const 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
3031const { mutate : deletePost, isLoading : isDeleting } = useMutation ({
You can’t perform that action at this time.
0 commit comments