@putkoff/abstract-utilities 0.1.207 → 0.1.209

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/esm/index.js CHANGED
@@ -405,6 +405,9 @@ function getResult(obj) {
405
405
  Object.prototype.hasOwnProperty.call(current, "result")) {
406
406
  current = current.result;
407
407
  }
408
+ if (current === null || current === void 0 ? void 0 : current.result) {
409
+ current = current.result;
410
+ }
408
411
  return current;
409
412
  }
410
413
  // Determines HTTP method, defaults to GET or POST based on body
@@ -495,7 +498,7 @@ function checkResponse(res) {
495
498
  }
496
499
 
497
500
  function fetchIt(endpoint_1) {
498
- return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = false, configUrl = false, withCredentials = true, returnJson = true, returnReult = true) {
501
+ return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = false, configUrl = false, withCredentials = true, returnJson = true, returnResult = true) {
499
502
  method = (method || "GET").toUpperCase();
500
503
  // 2) choose the URL
501
504
  let url = endpoint;
@@ -512,17 +515,20 @@ function fetchIt(endpoint_1) {
512
515
  : undefined,
513
516
  };
514
517
  console.debug("➡️ secureFetchIt →", url, opts);
515
- const res = yield fetch(url, opts);
518
+ let res = yield fetch(url, opts);
516
519
  if (!res.ok) {
517
520
  const err = yield res.text();
518
521
  throw new Error(`HTTP ${res.status}: ${err}`);
519
522
  }
520
523
  if (blob)
521
524
  return res.blob();
522
- if (returnReult)
523
- return getResult(res.json());
524
- if (returnJson)
525
- return res.json();
525
+ if (returnResult || returnJson) {
526
+ let JsonRes = parseResult(res);
527
+ if (returnResult) {
528
+ JsonRes = getResult(JsonRes);
529
+ }
530
+ return JsonRes;
531
+ }
526
532
  return res;
527
533
  });
528
534
  }