kayto_ts 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -228,7 +228,7 @@ const clientWithHooks = clientApi<CatsEndpoints>({
|
|
|
228
228
|
|
|
229
229
|
All requests return a discriminated union:
|
|
230
230
|
|
|
231
|
-
- success: `{ ok: true,
|
|
231
|
+
- success: `{ ok: true, responses, response }`
|
|
232
232
|
- failure: `{ ok: false, error, response? }`
|
|
233
233
|
|
|
234
234
|
`error.kind` values:
|
|
@@ -246,6 +246,15 @@ You can also handle them generically via `message` / `status` / `cause` without
|
|
|
246
246
|
```ts
|
|
247
247
|
const result = await client.get("/api/cats");
|
|
248
248
|
|
|
249
|
+
if (result.ok) {
|
|
250
|
+
const success = result.responses[200];
|
|
251
|
+
console.log(success);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
const result = await client.get("/api/cats");
|
|
257
|
+
|
|
249
258
|
if (!result.ok) {
|
|
250
259
|
console.error("Request failed:", result.error.message);
|
|
251
260
|
|
|
@@ -291,5 +300,5 @@ Client parses response body automatically by `content-type`:
|
|
|
291
300
|
## Notes
|
|
292
301
|
|
|
293
302
|
- Runtime shape validation is not built in yet (current typing is compile-time only).
|
|
294
|
-
- If you need runtime validation, validate `result.
|
|
303
|
+
- If you need runtime validation, validate `result.responses[statusCode]` in consumer code (ArkType/Zod/etc.).
|
|
295
304
|
- Current entrypoint is `src/index.ts`.
|