@putkoff/abstract-utilities 0.1.182 → 0.1.183
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 +18 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +18 -8
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1428,21 +1428,31 @@ function checkResponse(res) {
|
|
|
1428
1428
|
}
|
|
1429
1429
|
return res;
|
|
1430
1430
|
}
|
|
1431
|
-
function fetchIt(
|
|
1432
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
1433
|
-
method = method || "GET";
|
|
1434
|
-
|
|
1435
|
-
|
|
1431
|
+
function fetchIt(endpoint_1) {
|
|
1432
|
+
return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = false, noApi = false, withCredentials = true, returnJson = true, returnReult = true) {
|
|
1433
|
+
method = (method || "GET").toUpperCase();
|
|
1434
|
+
// 1) auto-detect absolute URLs
|
|
1435
|
+
const isAbsolute = typeof endpoint === "string" && /^https?:\/\//i.test(endpoint);
|
|
1436
|
+
// 2) choose the URL
|
|
1437
|
+
let url;
|
|
1438
|
+
if (isAbsolute) {
|
|
1439
|
+
url = endpoint;
|
|
1436
1440
|
}
|
|
1437
|
-
|
|
1441
|
+
else if (noApi) {
|
|
1442
|
+
url = endpoint;
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
url = yield get_app_config_url(endpoint);
|
|
1446
|
+
}
|
|
1447
|
+
// 3) prepare headers & body
|
|
1438
1448
|
headers = Object.assign(Object.assign(Object.assign({}, (body instanceof FormData ? {} : { "Content-Type": "application/json" })), getAuthorizationHeader()), headers);
|
|
1439
1449
|
const opts = {
|
|
1440
|
-
method
|
|
1450
|
+
method,
|
|
1441
1451
|
credentials: withCredentials ? "include" : "same-origin",
|
|
1442
1452
|
headers,
|
|
1443
1453
|
body: body instanceof FormData
|
|
1444
1454
|
? body
|
|
1445
|
-
: body != null && method
|
|
1455
|
+
: body != null && method !== "GET"
|
|
1446
1456
|
? JSON.stringify(body)
|
|
1447
1457
|
: undefined,
|
|
1448
1458
|
};
|