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