We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ea9b56 commit 17ec2baCopy full SHA for 17ec2ba
src/routes/solid-router/reference/data-apis/query.mdx
@@ -101,3 +101,22 @@ const getUserProfileQuery = query(async (userId: string) => {
101
return json;
102
}, "userProfile");
103
```
104
+
105
+### Server usage
106
+```tsx
107
+import { query } from "@solidjs/router";
108
109
+const getUserProfileQuery = query(async (userId: string) => {
110
+ "use server";
111
112
+ const response = await fetch(
113
+ `https://api.example.com/users/${encodeURIComponent(userId)}`
114
+ );
115
+ const json = await response.json();
116
117
+ if (!response.ok) {
118
+ throw new Error(json?.message ?? "Failed to load user profile.");
119
+ }
120
121
+ return json;
122
+}, "userProfile");
0 commit comments