You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 26, 2026. It is now read-only.
Repository navigation
Commit 8f4cfe6
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: apps/docs/docs/core/fetch.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,6 +145,51 @@ This will ensure that you could pass Date objects in your client queries. They w
145
145
146
146
:::
147
147
148
+
## Validate Response
149
+
150
+
The `validateResponse` option allows you to validate the response body against the response schema. This is useful for ensuring that the server is returning the correct response type or performing transformations that are part of the response schema. For this to work, the responses schema must be defined using Zod (`c.type<>` will not check types at runtime).
// response will be validated against the response schema
168
+
if (response.status===200) {
169
+
// response.data will be of type { id: string, createdAt: Date }
170
+
// because `createdAt` has transformation of `z.coerce.date()`, it will parse any string date into a Date object
171
+
}
172
+
```
173
+
174
+
:::caution
175
+
176
+
If you are doing any non-idempotent Zod transforms that run on the server, response validation may fail on the client or produce an unintended double transformation is certain cases. Make sure your transformations are idempotent.
0 commit comments