getta 1.0.10 → 1.0.11
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.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/production.analysis.txt +14 -14
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/main.ts +17 -8
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -219,7 +219,7 @@ export class Getta {
|
|
|
219
219
|
context.startTime = this._performance.now();
|
|
220
220
|
|
|
221
221
|
try {
|
|
222
|
-
const { redirects, retries, ...rest } = options;
|
|
222
|
+
const { headers: requestHeaders, redirects, retries, ...rest } = options;
|
|
223
223
|
|
|
224
224
|
return await new Promise<FetchResponse>((resolve, reject) => {
|
|
225
225
|
void (async () => {
|
|
@@ -239,14 +239,21 @@ export class Getta {
|
|
|
239
239
|
|
|
240
240
|
if (!redirects && !retries) {
|
|
241
241
|
this._log?.(consts.REQUEST_SENT, {
|
|
242
|
-
context: {
|
|
242
|
+
context: {
|
|
243
|
+
fetchRedirets: redirects,
|
|
244
|
+
fetchRetries: retries,
|
|
245
|
+
fetchUrl: endpoint,
|
|
246
|
+
requestHeaders,
|
|
247
|
+
...rest,
|
|
248
|
+
...context,
|
|
249
|
+
},
|
|
243
250
|
stats: { startTime: context.startTime },
|
|
244
251
|
});
|
|
245
252
|
}
|
|
246
253
|
|
|
247
254
|
// Casting as fetch response does not support generics.
|
|
248
255
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
249
|
-
const res = (await fetch(endpoint, rest)) as FetchResponse;
|
|
256
|
+
const res = (await fetch(endpoint, { ...rest, headers: requestHeaders })) as FetchResponse;
|
|
250
257
|
|
|
251
258
|
clearTimeout(fetchTimer);
|
|
252
259
|
|
|
@@ -261,6 +268,7 @@ export class Getta {
|
|
|
261
268
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
262
269
|
headers.get(consts.LOCATION_HEADER)!,
|
|
263
270
|
{
|
|
271
|
+
headers: requestHeaders,
|
|
264
272
|
redirects,
|
|
265
273
|
status,
|
|
266
274
|
...rest,
|
|
@@ -278,6 +286,7 @@ export class Getta {
|
|
|
278
286
|
res,
|
|
279
287
|
endpoint,
|
|
280
288
|
{
|
|
289
|
+
headers: requestHeaders,
|
|
281
290
|
retries,
|
|
282
291
|
...rest,
|
|
283
292
|
},
|
|
@@ -312,7 +321,7 @@ export class Getta {
|
|
|
312
321
|
const endTime = this._performance.now();
|
|
313
322
|
|
|
314
323
|
this._log?.(consts.REQUEST_FAILED, {
|
|
315
|
-
context: { error,
|
|
324
|
+
context: { error, fetchUrl: endpoint, ...rest },
|
|
316
325
|
stats: { duration: startTime ? endTime - startTime : 0, endTime, startTime },
|
|
317
326
|
});
|
|
318
327
|
|
|
@@ -452,12 +461,12 @@ export class Getta {
|
|
|
452
461
|
|
|
453
462
|
this._log?.(consts.RESPONSE_RECEIVED, {
|
|
454
463
|
context: {
|
|
455
|
-
|
|
464
|
+
fetchRedirects: redirects,
|
|
465
|
+
fetchRetries: retries,
|
|
466
|
+
fetchUrl: endpoint,
|
|
456
467
|
method,
|
|
457
|
-
|
|
458
|
-
retries,
|
|
468
|
+
responseHeaders: headers,
|
|
459
469
|
status,
|
|
460
|
-
url: endpoint,
|
|
461
470
|
...otherContext,
|
|
462
471
|
},
|
|
463
472
|
stats: { duration, endTime, startTime },
|