@putkoff/abstract-utilities 0.1.207 → 0.1.208

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