@@ -176,10 +176,15 @@ export default function createClient(clientOptions) {
176
176
return { error, response } ;
177
177
}
178
178
179
- // Poor-man's set.
180
- const methods = { GET : 0 , PUT : 0 , POST : 0 , DELETE : 0 , OPTIONS : 0 , HEAD : 0 , PATCH : 0 , TRACE : 0 } ;
179
+ const methods = [ "GET" , "PUT" , "POST" , "DELETE" , "OPTIONS" , "HEAD" , "PATCH" , "TRACE" ] ;
180
+
181
+ const methodMembers = Object . fromEntries (
182
+ methods . map ( ( method ) => [ method , ( url , init ) => coreFetch ( url , { ...init , method } ) ] ) ,
183
+ ) ;
181
184
182
185
const coreClient = {
186
+ ...methodMembers ,
187
+
183
188
/** Register middleware */
184
189
use ( ...middleware ) {
185
190
for ( const m of middleware ) {
@@ -209,13 +214,9 @@ export default function createClient(clientOptions) {
209
214
return coreClient [ property ] ;
210
215
}
211
216
212
- if ( property in methods ) {
213
- return ( url , init ) => coreFetch ( url , { ...init , method : property } ) ;
214
- }
215
-
216
- // Assume the property is a URL.
217
+ // Assume the property is an URL.
217
218
return Object . fromEntries (
218
- Object . keys ( methods ) . map ( ( method ) => [ method , ( init ) => coreFetch ( property , { ...init , method } ) ] ) ,
219
+ methods . map ( ( method ) => [ method , ( init ) => coreFetch ( property , { ...init , method } ) ] ) ,
219
220
) ;
220
221
} ,
221
222
} ;
0 commit comments