@@ -140,36 +140,36 @@ export default function createClient<T>(defaultOptions?: ClientOptions) {
140
140
141
141
return {
142
142
/** Call a GET endpoint */
143
- async get < U extends PathsWith < 'get' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
144
- return coreFetch ( url , { ...options , method : 'GET' } ) ;
143
+ async get < U extends PathsWith < 'get' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
144
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'GET' } ) ;
145
145
} ,
146
146
/** Call a PUT endpoint */
147
- async put < U extends PathsWith < 'put' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
148
- return coreFetch ( url , { ...options , method : 'PUT' } ) ;
147
+ async put < U extends PathsWith < 'put' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
148
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'PUT' } ) ;
149
149
} ,
150
150
/** Call a POST endpoint */
151
- async post < U extends PathsWith < 'post' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
152
- return coreFetch ( url , { ...options , method : 'POST' } ) ;
151
+ async post < U extends PathsWith < 'post' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
152
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'POST' } ) ;
153
153
} ,
154
154
/** Call a DELETE endpoint */
155
- async del < U extends PathsWith < 'delete' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
156
- return coreFetch ( url , { ...options , method : 'DELETE' } ) ;
155
+ async del < U extends PathsWith < 'delete' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
156
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'DELETE' } ) ;
157
157
} ,
158
158
/** Call a OPTIONS endpoint */
159
- async options < U extends PathsWith < 'options' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
160
- return coreFetch ( url , { ...options , method : 'OPTIONS' } ) ;
159
+ async options < U extends PathsWith < 'options' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
160
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'OPTIONS' } ) ;
161
161
} ,
162
162
/** Call a HEAD endpoint */
163
- async head < U extends PathsWith < 'head' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
164
- return coreFetch ( url , { ...options , method : 'HEAD' } ) ;
163
+ async head < U extends PathsWith < 'head' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
164
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'HEAD' } ) ;
165
165
} ,
166
166
/** Call a PATCH endpoint */
167
- async patch < U extends PathsWith < 'patch' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
168
- return coreFetch ( url , { ...options , method : 'PATCH' } ) ;
167
+ async patch < U extends PathsWith < 'patch' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
168
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'PATCH' } ) ;
169
169
} ,
170
170
/** Call a TRACE endpoint */
171
- async trace < U extends PathsWith < 'trace' > , M extends keyof T [ U ] > ( url : U , options : FetchOptions < U , M > ) {
172
- return coreFetch ( url , { ...options , method : 'TRACE' } ) ;
171
+ async trace < U extends PathsWith < 'trace' > , M extends keyof T [ U ] > ( url : U , options ? : FetchOptions < U , M > ) {
172
+ return coreFetch ( url , { ...( options ?? ( { } as FetchOptions < U , M > ) ) , method : 'TRACE' } ) ;
173
173
} ,
174
174
} ;
175
175
}
0 commit comments