File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,14 @@ const getUsers = async () => {
33 return await $fetch (' https://jsonplaceholder.typicode.com/users' )
44}
55
6- const { isPending : isPending, data : users } = useQuery ({
6+ const { isPending : isPending, data : users, suspense } = useQuery ({
77 queryKey: [' users' ],
88 queryFn: getUsers ,
99})
10+
11+ onServerPrefetch (async () => {
12+ await suspense ()
13+ })
1014 </script >
1115
1216<template >
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const getPosts = async (userId) => {
1212 return await $fetch (url, { method: ' GET' , params: { userId } })
1313}
1414
15- const { isPending: isUsersPending , data: users } = useQuery ({
15+ const { isPending: isUsersPending , data: users , suspense } = useQuery ({
1616 queryKey: [' users' ],
1717 queryFn: getUsers,
1818})
@@ -42,6 +42,10 @@ const { mutate: addPost, isPending: isMutationPending } = useMutation({
4242 },
4343})
4444
45+ onServerPrefetch (async () => {
46+ await suspense ()
47+ })
48+
4549function selectUser (user ) {
4650 selectedUser .value = user
4751}
You can’t perform that action at this time.
0 commit comments