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