File tree 2 files changed +15
-12
lines changed
2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 8
8
" big-swans-rush" ,
9
9
" chilled-bears-learn" ,
10
10
" eleven-crabs-breathe" ,
11
+ " fifty-zoos-wait" ,
11
12
" light-pandas-whisper" ,
12
13
" old-onions-invite" ,
13
14
" rare-knives-drive" ,
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ const getTodos = async (id: number) => {
54
54
getTodos (1 );
55
55
```
56
56
57
-
58
57
## Example with Schema Validation (with Zod)
59
58
60
59
``` typescript
@@ -72,24 +71,27 @@ const apiClient = new Aspi({
72
71
const getTodo = async (id : number ) => {
73
72
const response = await apiClient
74
73
.get (` /todos/${id } ` )
75
- .output (z .object ({
76
- id: z .number (),
77
- title: z .string (),
78
- completed: z .boolean (),
79
- }))
74
+ .output (
75
+ z .object ({
76
+ id: z .number (),
77
+ title: z .string (),
78
+ completed: z .boolean (),
79
+ }),
80
+ )
80
81
.json ();
81
82
82
83
Result .match (response , {
83
84
onOk : (data ) => {
84
85
console .log (data );
85
86
},
86
- onErr : err => {
87
- if (err .tag === " parseError" ) {
87
+ onErr : ( err ) => {
88
+ if (err .tag === ' parseError' ) {
88
89
const error = err .data as ZodError ;
89
90
console .error (error .errors );
90
- }else {
91
+ } else {
91
92
// do something else
92
93
}
93
- }
94
- })
95
- }
94
+ },
95
+ });
96
+ };
97
+ ```
You can’t perform that action at this time.
0 commit comments