create-request 1.3.0 → 1.3.1

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.
@@ -96,6 +96,12 @@ var CacheMode;
96
96
  })(CacheMode || (CacheMode = {}));
97
97
 
98
98
  class RequestError extends Error {
99
+ status;
100
+ response;
101
+ url;
102
+ method;
103
+ isTimeout;
104
+ isAborted;
99
105
  constructor(message, url, method, options = {}) {
100
106
  super(message);
101
107
  this.name = "RequestError";
@@ -194,6 +200,11 @@ class RequestError extends Error {
194
200
  * Wrapper for HTTP responses with methods to transform the response data
195
201
  */
196
202
  class ResponseWrapper {
203
+ response;
204
+ url;
205
+ method;
206
+ // GraphQL-specific options
207
+ graphQLOptions;
197
208
  constructor(response, url, method, graphQLOptions) {
198
209
  this.response = response;
199
210
  this.url = url;
@@ -226,8 +237,7 @@ class ResponseWrapper {
226
237
  * @throws RequestError if GraphQL response contains errors and throwOnError is enabled
227
238
  */
228
239
  checkGraphQLErrors(data) {
229
- var _a;
230
- if (!((_a = this.graphQLOptions) === null || _a === void 0 ? void 0 : _a.throwOnError) || typeof data !== "object" || data === null)
240
+ if (!this.graphQLOptions?.throwOnError || typeof data !== "object" || data === null)
231
241
  return;
232
242
  const responseData = data;
233
243
  if (!Array.isArray(responseData.errors) || responseData.errors.length === 0)
@@ -488,7 +498,7 @@ class CsrfUtils {
488
498
  return null;
489
499
  }
490
500
  const meta = document.querySelector(`meta[name="${metaName}"]`);
491
- return (meta === null || meta === void 0 ? void 0 : meta.getAttribute("content")) || null;
501
+ return meta?.getAttribute("content") || null;
492
502
  }
493
503
  /**
494
504
  * Extracts CSRF token from a cookie
@@ -545,20 +555,20 @@ class CsrfUtils {
545
555
  * Global configuration for create-request
546
556
  */
547
557
  class Config {
548
- constructor() {
549
- // CSRF configuration
550
- this.csrfHeaderName = "X-CSRF-Token";
551
- this.xsrfCookieName = "XSRF-TOKEN";
552
- this.xsrfHeaderName = "X-XSRF-TOKEN";
553
- this.csrfToken = null;
554
- this.enableAutoXsrf = true;
555
- this.enableAntiCsrf = true; // X-Requested-With header
556
- // Interceptor configuration
557
- this.requestInterceptors = [];
558
- this.responseInterceptors = [];
559
- this.errorInterceptors = [];
560
- this.nextInterceptorId = 1;
561
- }
558
+ static instance;
559
+ // CSRF configuration
560
+ csrfHeaderName = "X-CSRF-Token";
561
+ xsrfCookieName = "XSRF-TOKEN";
562
+ xsrfHeaderName = "X-XSRF-TOKEN";
563
+ csrfToken = null;
564
+ enableAutoXsrf = true;
565
+ enableAntiCsrf = true; // X-Requested-With header
566
+ // Interceptor configuration
567
+ requestInterceptors = [];
568
+ responseInterceptors = [];
569
+ errorInterceptors = [];
570
+ nextInterceptorId = 1;
571
+ constructor() { }
562
572
  /**
563
573
  * Get the singleton instance of the Config class
564
574
  *
@@ -841,16 +851,18 @@ class Config {
841
851
  * Provides the core request building and execution capabilities.
842
852
  */
843
853
  class BaseRequest {
854
+ url;
855
+ requestOptions = {
856
+ headers: {},
857
+ };
858
+ abortController;
859
+ queryParams = new URLSearchParams();
860
+ autoApplyCsrfProtection = true;
861
+ // Per-request interceptors
862
+ requestInterceptors = [];
863
+ responseInterceptors = [];
864
+ errorInterceptors = [];
844
865
  constructor(url) {
845
- this.requestOptions = {
846
- headers: {},
847
- };
848
- this.queryParams = new URLSearchParams();
849
- this.autoApplyCsrfProtection = true;
850
- // Per-request interceptors
851
- this.requestInterceptors = [];
852
- this.responseInterceptors = [];
853
- this.errorInterceptors = [];
854
866
  this.url = url;
855
867
  }
856
868
  /**
@@ -881,7 +893,7 @@ class BaseRequest {
881
893
  return Object.assign(callable, fluent);
882
894
  }
883
895
  validateUrl(url) {
884
- if (!(url === null || url === void 0 ? void 0 : url.trim()))
896
+ if (!url?.trim())
885
897
  throw new RequestError("URL cannot be empty", url, this.method);
886
898
  if (url.includes("\0") || url.includes("\r") || url.includes("\n")) {
887
899
  throw new RequestError("Invalid URL (control chars)", url, this.method);
@@ -891,7 +903,7 @@ class BaseRequest {
891
903
  try {
892
904
  new URL(trimmed);
893
905
  }
894
- catch (_a) {
906
+ catch {
895
907
  throw new RequestError(`Invalid URL: ${trimmed}`, trimmed, this.method);
896
908
  }
897
909
  }
@@ -990,10 +1002,26 @@ class BaseRequest {
990
1002
  return this;
991
1003
  }
992
1004
  /**
993
- * Sets credentials policy - supports both direct call and fluent API
1005
+ * Sets the credentials policy for the request, controlling whether cookies and authentication
1006
+ * headers are sent with cross-origin requests.
1007
+ *
1008
+ * @param credentialsPolicy - The credentials policy to use:
1009
+ * - `"include"` or `CredentialsPolicy.INCLUDE`: Always send credentials (cookies, authorization headers) with the request, even for cross-origin requests.
1010
+ * - `"omit"` or `CredentialsPolicy.OMIT`: Never send credentials, even for same-origin requests.
1011
+ * - `"same-origin"` or `CredentialsPolicy.SAME_ORIGIN`: Only send credentials for same-origin requests (default behavior in most browsers).
1012
+ *
1013
+ * @returns The request instance for chaining
1014
+ *
994
1015
  * @example
1016
+ * // Using string values
995
1017
  * request.withCredentials("include")
1018
+ *
1019
+ * @example
1020
+ * // Using enum values
996
1021
  * request.withCredentials(CredentialsPolicy.INCLUDE)
1022
+ *
1023
+ * @example
1024
+ * // Using fluent API
997
1025
  * request.withCredentials.INCLUDE()
998
1026
  */
999
1027
  get withCredentials() {
@@ -1004,28 +1032,83 @@ class BaseRequest {
1004
1032
  });
1005
1033
  }
1006
1034
  /**
1007
- * Allows providing an external AbortController to cancel the request
1008
- * @param controller - The AbortController to use for this request
1009
- * @returns The instance for chaining
1035
+ * Allows providing an external AbortController to cancel the request.
1036
+ * This is useful when you need to cancel a request from outside the request chain,
1037
+ *
1038
+ * @param controller - The AbortController to use for this request. When `controller.abort()` is called,
1039
+ * the request will be cancelled and throw an abort error.
1040
+ *
1041
+ * @returns The request instance for chaining
1042
+ *
1043
+ * @example
1044
+ * const controller = new AbortController();
1045
+ * const request = createRequest('/api/data')
1046
+ * .withAbortController(controller)
1047
+ * .getJson();
1048
+ *
1049
+ * // Later, cancel the request
1050
+ * controller.abort();
1051
+ *
1052
+ * @example
1053
+ * // Share abort controller across multiple requests
1054
+ * const controller = new AbortController();
1055
+ * request1.withAbortController(controller).getJson();
1056
+ * request2.withAbortController(controller).getJson();
1057
+ * // Aborting will cancel both requests
1058
+ * controller.abort();
1010
1059
  */
1011
1060
  withAbortController(controller) {
1012
1061
  this.abortController = controller;
1013
1062
  return this;
1014
1063
  }
1015
1064
  /**
1016
- * Sets the referrer for the request
1017
- * @param referrer - The referrer URL or policy
1018
- * @returns The instance for chaining
1065
+ * Sets the referrer URL for the request. The referrer is the URL of the page that initiated the request.
1066
+ * This can be used to override the default referrer that the browser would normally send.
1067
+ *
1068
+ * @param referrer - The referrer URL to send with the request. Can be:
1069
+ * - A full URL (e.g., "https://example.com/page")
1070
+ * - An empty string to omit the referrer
1071
+ * - A relative URL (will be resolved relative to the current page)
1072
+ *
1073
+ * @returns The request instance for chaining
1074
+ *
1075
+ * @example
1076
+ * request.withReferrer("https://example.com/previous-page")
1077
+ *
1078
+ * @example
1079
+ * // Omit referrer
1080
+ * request.withReferrer("")
1019
1081
  */
1020
1082
  withReferrer(referrer) {
1021
1083
  this.requestOptions.referrer = referrer;
1022
1084
  return this;
1023
1085
  }
1024
1086
  /**
1025
- * Sets referrer policy - supports both direct call and fluent API
1087
+ * Sets the referrer policy for the request, controlling how much referrer information
1088
+ * is sent with the request. This helps balance privacy and functionality.
1089
+ *
1090
+ * @param policy - The referrer policy to use:
1091
+ * - `"no-referrer"` or `ReferrerPolicy.NO_REFERRER`: Never send the referrer header.
1092
+ * - `"no-referrer-when-downgrade"` or `ReferrerPolicy.NO_REFERRER_WHEN_DOWNGRADE`: Send full referrer for same-origin or HTTPS→HTTPS, omit for HTTPS→HTTP (default in most browsers).
1093
+ * - `"origin"` or `ReferrerPolicy.ORIGIN`: Only send the origin (scheme, host, port), not the full URL.
1094
+ * - `"origin-when-cross-origin"` or `ReferrerPolicy.ORIGIN_WHEN_CROSS_ORIGIN`: Send full referrer for same-origin, only origin for cross-origin.
1095
+ * - `"same-origin"` or `ReferrerPolicy.SAME_ORIGIN`: Send full referrer for same-origin requests only, omit for cross-origin.
1096
+ * - `"strict-origin"` or `ReferrerPolicy.STRICT_ORIGIN`: Send origin for HTTPS→HTTPS or HTTP→HTTP, omit for HTTPS→HTTP.
1097
+ * - `"strict-origin-when-cross-origin"` or `ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN`: Send full referrer for same-origin, origin for cross-origin HTTPS→HTTPS, omit for HTTPS→HTTP.
1098
+ * - `"unsafe-url"` or `ReferrerPolicy.UNSAFE_URL`: Always send the full referrer URL (may leak sensitive information).
1099
+ *
1100
+ * @returns The request instance for chaining
1101
+ *
1026
1102
  * @example
1103
+ * // Using string values
1027
1104
  * request.withReferrerPolicy("no-referrer")
1105
+ *
1106
+ * @example
1107
+ * // Using enum values
1028
1108
  * request.withReferrerPolicy(ReferrerPolicy.NO_REFERRER)
1109
+ *
1110
+ * @example
1111
+ * // Using fluent API
1029
1112
  * request.withReferrerPolicy.NO_REFERRER()
1030
1113
  */
1031
1114
  get withReferrerPolicy() {
@@ -1041,11 +1124,30 @@ class BaseRequest {
1041
1124
  });
1042
1125
  }
1043
1126
  /**
1044
- * Sets redirect mode - supports both direct call and fluent API
1127
+ * Sets how the request handles HTTP redirects (3xx status codes).
1128
+ *
1129
+ * @param redirect - The redirect handling mode:
1130
+ * - `"follow"` or `RedirectMode.FOLLOW`: Automatically follow redirects. The fetch will transparently follow redirects and return the final response (default behavior).
1131
+ * - `"error"` or `RedirectMode.ERROR`: Treat redirects as errors. If a redirect occurs, the request will fail with an error.
1132
+ * - `"manual"` or `RedirectMode.MANUAL`: Return the redirect response without following it. The response will have a `type` of "opaqueredirect" and you can manually handle the redirect.
1133
+ *
1134
+ * @returns The request instance for chaining
1135
+ *
1045
1136
  * @example
1137
+ * // Using string values
1046
1138
  * request.withRedirect("follow")
1139
+ *
1140
+ * @example
1141
+ * // Using enum values
1047
1142
  * request.withRedirect(RedirectMode.FOLLOW)
1143
+ *
1144
+ * @example
1145
+ * // Using fluent API
1048
1146
  * request.withRedirect.FOLLOW()
1147
+ *
1148
+ * @example
1149
+ * // Fail on redirects
1150
+ * request.withRedirect.ERROR()
1049
1151
  */
1050
1152
  get withRedirect() {
1051
1153
  return this.createFluentSetter("redirect", {
@@ -1055,20 +1157,50 @@ class BaseRequest {
1055
1157
  });
1056
1158
  }
1057
1159
  /**
1058
- * Sets the keepalive flag for the request
1059
- * @param keepalive - Whether to allow the request to outlive the page
1060
- * @returns The instance for chaining
1160
+ * Sets the keepalive flag for the request. When enabled, the request can continue
1161
+ * even after the page that initiated it is closed. This is useful for analytics,
1162
+ * logging, or other background requests that should complete even if the user navigates away.
1163
+ *
1164
+ * @param keepalive - Whether to allow the request to outlive the page:
1165
+ * - `true`: The request will continue even if the page is closed or navigated away.
1166
+ * - `false`: The request will be cancelled if the page is closed (default).
1167
+ *
1168
+ * @returns The request instance for chaining
1169
+ *
1170
+ * @example
1171
+ * // Send analytics event that should complete even if user navigates away
1172
+ * request.withKeepAlive(true)
1061
1173
  */
1062
1174
  withKeepAlive(keepalive) {
1063
1175
  this.requestOptions.keepalive = keepalive;
1064
1176
  return this;
1065
1177
  }
1066
1178
  /**
1067
- * Sets request priority - supports both direct call and fluent API
1179
+ * Sets the priority hint for the request, indicating to the browser how important
1180
+ * this request is relative to other requests. This helps the browser optimize resource loading.
1181
+ *
1182
+ * @param priority - The request priority:
1183
+ * - `"high"` or `RequestPriority.HIGH`: High priority - the browser should prioritize this request.
1184
+ * - `"low"` or `RequestPriority.LOW`: Low priority - the browser can defer this request if needed.
1185
+ * - `"auto"` or `RequestPriority.AUTO`: Automatic priority based on the request type (default).
1186
+ *
1187
+ * @returns The request instance for chaining
1188
+ *
1068
1189
  * @example
1190
+ * // Using string values
1069
1191
  * request.withPriority("high")
1192
+ *
1193
+ * @example
1194
+ * // Using enum values
1070
1195
  * request.withPriority(RequestPriority.HIGH)
1196
+ *
1197
+ * @example
1198
+ * // Using fluent API
1071
1199
  * request.withPriority.HIGH()
1200
+ *
1201
+ * @example
1202
+ * // Low priority for non-critical requests
1203
+ * request.withPriority.LOW()
1072
1204
  */
1073
1205
  get withPriority() {
1074
1206
  return this.createFluentSetter("priority", {
@@ -1078,22 +1210,62 @@ class BaseRequest {
1078
1210
  });
1079
1211
  }
1080
1212
  /**
1081
- * Sets the integrity hash for subresource integrity verification
1082
- * @param integrity - The integrity hash string (e.g., "sha256-...")
1083
- * @returns The instance for chaining
1213
+ * Sets the integrity hash for Subresource Integrity (SRI) verification.
1214
+ * This allows the browser to verify that the fetched resource hasn't been tampered with
1215
+ * by comparing its hash against the provided value. If the hashes don't match, the request fails.
1216
+ *
1217
+ * @param integrity - The integrity hash string in the format `"algorithm-hash"`:
1218
+ * - Example: `"sha256-abcdef1234567890..."` (SHA-256 hash)
1219
+ * - Example: `"sha384-abcdef1234567890..."` (SHA-384 hash)
1220
+ * - Example: `"sha512-abcdef1234567890..."` (SHA-512 hash)
1221
+ * - Multiple hashes can be separated by spaces: `"sha256-... sha384-..."`
1222
+ *
1223
+ * @returns The request instance for chaining
1224
+ *
1084
1225
  * @example
1085
1226
  * request.withIntegrity("sha256-abcdef1234567890...")
1227
+ *
1228
+ * @example
1229
+ * // Multiple algorithms for better compatibility
1230
+ * request.withIntegrity("sha256-... sha384-...")
1086
1231
  */
1087
1232
  withIntegrity(integrity) {
1088
1233
  this.requestOptions.integrity = integrity;
1089
1234
  return this;
1090
1235
  }
1091
1236
  /**
1092
- * Sets cache mode - supports both direct call and fluent API
1237
+ * Sets the cache mode for the request, controlling how the browser's HTTP cache
1238
+ * is used for this request.
1239
+ *
1240
+ * @param cache - The cache mode:
1241
+ * - `"default"` or `CacheMode.DEFAULT`: Use the browser's default cache behavior. The browser will check the cache and use it if valid, otherwise fetch from network.
1242
+ * - `"no-store"` or `CacheMode.NO_STORE`: Never use the cache and don't store the response in cache. Always fetch from network.
1243
+ * - `"reload"` or `CacheMode.RELOAD`: Bypass the cache but store the response. Always fetch from network, ignoring cached responses.
1244
+ * - `"no-cache"` or `CacheMode.NO_CACHE`: Check the cache but revalidate with the server. Use cached response only if server confirms it's still valid.
1245
+ * - `"force-cache"` or `CacheMode.FORCE_CACHE`: Use the cache if available, even if stale. Only fetch from network if not in cache.
1246
+ * - `"only-if-cached"` or `CacheMode.ONLY_IF_CACHED`: Only use the cache. If not in cache, return an error. Never fetch from network.
1247
+ *
1248
+ * @returns The request instance for chaining
1249
+ *
1093
1250
  * @example
1251
+ * // Using string values
1094
1252
  * request.withCache("no-cache")
1253
+ *
1254
+ * @example
1255
+ * // Using enum values
1095
1256
  * request.withCache(CacheMode.NO_CACHE)
1257
+ *
1258
+ * @example
1259
+ * // Using fluent API
1096
1260
  * request.withCache.NO_CACHE()
1261
+ *
1262
+ * @example
1263
+ * // Always fetch fresh data
1264
+ * request.withCache.RELOAD()
1265
+ *
1266
+ * @example
1267
+ * // Use cache only, fail if not cached
1268
+ * request.withCache.ONLY_IF_CACHED()
1097
1269
  */
1098
1270
  get withCache() {
1099
1271
  const cacheOptions = {
@@ -1142,11 +1314,32 @@ class BaseRequest {
1142
1314
  return this;
1143
1315
  }
1144
1316
  /**
1145
- * Sets request mode - supports both direct call and fluent API
1317
+ * Sets the request mode, which determines the CORS (Cross-Origin Resource Sharing) behavior
1318
+ * for the request. This controls how the browser handles cross-origin requests.
1319
+ *
1320
+ * @param mode - The request mode:
1321
+ * - `"cors"` or `RequestMode.CORS`: Enable CORS. The browser will send CORS headers and enforce CORS rules. This is the default for most cross-origin requests.
1322
+ * - `"no-cors"` or `RequestMode.NO_CORS`: Disable CORS. The request is sent as a "simple" request without CORS headers. The response will be opaque (you can't read it).
1323
+ * - `"same-origin"` or `RequestMode.SAME_ORIGIN`: Only allow same-origin requests. Cross-origin requests will fail.
1324
+ * - `"navigate"` or `RequestMode.NAVIGATE`: Used for navigation requests (typically only used by the browser itself).
1325
+ *
1326
+ * @returns The request instance for chaining
1327
+ *
1146
1328
  * @example
1329
+ * // Using string values
1147
1330
  * request.withMode("cors")
1331
+ *
1332
+ * @example
1333
+ * // Using enum values
1148
1334
  * request.withMode(RequestMode.CORS)
1335
+ *
1336
+ * @example
1337
+ * // Using fluent API
1149
1338
  * request.withMode.CORS()
1339
+ *
1340
+ * @example
1341
+ * // Restrict to same-origin only
1342
+ * request.withMode.SAME_ORIGIN()
1150
1343
  */
1151
1344
  get withMode() {
1152
1345
  return this.createFluentSetter("mode", {
@@ -1670,7 +1863,7 @@ class BaseRequest {
1670
1863
  // No timeout - just use external controller
1671
1864
  if (!timeoutMs) {
1672
1865
  return {
1673
- signal: externalController === null || externalController === void 0 ? void 0 : externalController.signal,
1866
+ signal: externalController?.signal,
1674
1867
  cleanup: () => { },
1675
1868
  wasTimeout: () => false,
1676
1869
  };
@@ -1853,9 +2046,11 @@ class BaseRequest {
1853
2046
  * Base class for requests that can have a body (POST, PUT, PATCH)
1854
2047
  */
1855
2048
  class BodyRequest extends BaseRequest {
2049
+ body;
2050
+ bodyType;
2051
+ graphQLOptions = undefined;
1856
2052
  constructor(url) {
1857
2053
  super(url);
1858
- this.graphQLOptions = undefined;
1859
2054
  }
1860
2055
  /**
1861
2056
  * Sets the body of the request
@@ -1870,7 +2065,13 @@ class BodyRequest extends BaseRequest {
1870
2065
  }
1871
2066
  else if (body !== null &&
1872
2067
  typeof body === "object" &&
1873
- !(body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof URLSearchParams || body instanceof ReadableStream)) {
2068
+ !(body instanceof FormData ||
2069
+ body instanceof Blob ||
2070
+ body instanceof File ||
2071
+ body instanceof ArrayBuffer ||
2072
+ ArrayBuffer.isView(body) || // Handles TypedArray and DataView
2073
+ body instanceof URLSearchParams ||
2074
+ body instanceof ReadableStream)) {
1874
2075
  this.bodyType = BodyType.JSON;
1875
2076
  this.setContentTypeIfNeeded("application/json");
1876
2077
  // Validate JSON is stringifiable early
@@ -2000,9 +2201,9 @@ class BodyRequest extends BaseRequest {
2000
2201
  * const data = await request.getData();
2001
2202
  */
2002
2203
  class GetRequest extends BaseRequest {
2204
+ method = exports.HttpMethod.GET;
2003
2205
  constructor(url) {
2004
2206
  super(url);
2005
- this.method = exports.HttpMethod.GET;
2006
2207
  }
2007
2208
  }
2008
2209
  /**
@@ -2014,9 +2215,9 @@ class GetRequest extends BaseRequest {
2014
2215
  * const response = await request.getResponse();
2015
2216
  */
2016
2217
  class HeadRequest extends BaseRequest {
2218
+ method = exports.HttpMethod.HEAD;
2017
2219
  constructor(url) {
2018
2220
  super(url);
2019
- this.method = exports.HttpMethod.HEAD;
2020
2221
  }
2021
2222
  }
2022
2223
  /**
@@ -2028,9 +2229,9 @@ class HeadRequest extends BaseRequest {
2028
2229
  * const response = await request.getResponse();
2029
2230
  */
2030
2231
  class OptionsRequest extends BaseRequest {
2232
+ method = exports.HttpMethod.OPTIONS;
2031
2233
  constructor(url) {
2032
2234
  super(url);
2033
- this.method = exports.HttpMethod.OPTIONS;
2034
2235
  }
2035
2236
  }
2036
2237
  /**
@@ -2042,9 +2243,9 @@ class OptionsRequest extends BaseRequest {
2042
2243
  * await request.getData();
2043
2244
  */
2044
2245
  class DeleteRequest extends BaseRequest {
2246
+ method = exports.HttpMethod.DELETE;
2045
2247
  constructor(url) {
2046
2248
  super(url);
2047
- this.method = exports.HttpMethod.DELETE;
2048
2249
  }
2049
2250
  }
2050
2251
  /**
@@ -2057,9 +2258,9 @@ class DeleteRequest extends BaseRequest {
2057
2258
  * const data = await request.getData();
2058
2259
  */
2059
2260
  class PostRequest extends BodyRequest {
2261
+ method = exports.HttpMethod.POST;
2060
2262
  constructor(url) {
2061
2263
  super(url);
2062
- this.method = exports.HttpMethod.POST;
2063
2264
  }
2064
2265
  }
2065
2266
  /**
@@ -2072,9 +2273,9 @@ class PostRequest extends BodyRequest {
2072
2273
  * const data = await request.getData();
2073
2274
  */
2074
2275
  class PutRequest extends BodyRequest {
2276
+ method = exports.HttpMethod.PUT;
2075
2277
  constructor(url) {
2076
2278
  super(url);
2077
- this.method = exports.HttpMethod.PUT;
2078
2279
  }
2079
2280
  }
2080
2281
  /**
@@ -2087,9 +2288,9 @@ class PutRequest extends BodyRequest {
2087
2288
  * const data = await request.getData();
2088
2289
  */
2089
2290
  class PatchRequest extends BodyRequest {
2291
+ method = exports.HttpMethod.PATCH;
2090
2292
  constructor(url) {
2091
2293
  super(url);
2092
- this.method = exports.HttpMethod.PATCH;
2093
2294
  }
2094
2295
  }
2095
2296