getta 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "getta",
3
3
  "description": "An isomorphic rest client based on the Fetch API.",
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "author": "Dylan Aubrey",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/getta",
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 { headers: requestHeaders, redirects, retries, ...rest } = options;
222
+ const { redirects, retries, ...rest } = options;
223
223
 
224
224
  return await new Promise<FetchResponse>((resolve, reject) => {
225
225
  void (async () => {
@@ -240,11 +240,12 @@ export class Getta {
240
240
  if (!redirects && !retries) {
241
241
  this._log?.(consts.REQUEST_SENT, {
242
242
  context: {
243
+ fetchMethod: rest.method,
243
244
  fetchRedirets: redirects,
245
+ fetchRequestHeaders: rest.headers,
244
246
  fetchRetries: retries,
245
247
  fetchUrl: endpoint,
246
- requestHeaders,
247
- ...rest,
248
+ logEntryName: 'FETCH_REQUEST_SENT',
248
249
  ...context,
249
250
  },
250
251
  stats: { startTime: context.startTime },
@@ -253,7 +254,7 @@ export class Getta {
253
254
 
254
255
  // Casting as fetch response does not support generics.
255
256
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
256
- const res = (await fetch(endpoint, { ...rest, headers: requestHeaders })) as FetchResponse;
257
+ const res = (await fetch(endpoint, rest)) as FetchResponse;
257
258
 
258
259
  clearTimeout(fetchTimer);
259
260
 
@@ -268,7 +269,6 @@ export class Getta {
268
269
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
269
270
  headers.get(consts.LOCATION_HEADER)!,
270
271
  {
271
- headers: requestHeaders,
272
272
  redirects,
273
273
  status,
274
274
  ...rest,
@@ -286,7 +286,6 @@ export class Getta {
286
286
  res,
287
287
  endpoint,
288
288
  {
289
- headers: requestHeaders,
290
289
  retries,
291
290
  ...rest,
292
291
  },
@@ -321,7 +320,7 @@ export class Getta {
321
320
  const endTime = this._performance.now();
322
321
 
323
322
  this._log?.(consts.REQUEST_FAILED, {
324
- context: { error, fetchUrl: endpoint, ...rest },
323
+ context: { error, fetchUrl: endpoint, logEntryName: 'FETCH_REQUEST_FAILED', ...rest },
325
324
  stats: { duration: startTime ? endTime - startTime : 0, endTime, startTime },
326
325
  });
327
326
 
@@ -461,12 +460,13 @@ export class Getta {
461
460
 
462
461
  this._log?.(consts.RESPONSE_RECEIVED, {
463
462
  context: {
463
+ fetchMethod: method,
464
464
  fetchRedirects: redirects,
465
+ fetchResponseHeaders: Object.fromEntries(headers.entries()),
466
+ fetchResponseStatus: status,
465
467
  fetchRetries: retries,
466
468
  fetchUrl: endpoint,
467
- method,
468
- responseHeaders: headers,
469
- status,
469
+ logEntryName: 'FETCH_RESPONSE_RECEIVED',
470
470
  ...otherContext,
471
471
  },
472
472
  stats: { duration, endTime, startTime },