nextemos 5.8.0 → 5.8.2
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/helpers/fetchRequest.js +10 -2
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ const fetchRequest = () => {
|
|
|
41
41
|
var _b;
|
|
42
42
|
var { url, method, params } = _a, options = __rest(_a, ["url", "method", "params"]);
|
|
43
43
|
const apiURL = new URL(url);
|
|
44
|
+
const isPreview = (options === null || options === void 0 ? void 0 : options.headers)["Preview"];
|
|
44
45
|
if (params) {
|
|
45
46
|
Object.keys(params).forEach((key) => {
|
|
46
47
|
if (Array.isArray(params[key])) {
|
|
@@ -52,6 +53,9 @@ const fetchRequest = () => {
|
|
|
52
53
|
apiURL.searchParams.append(key, params[key]);
|
|
53
54
|
}
|
|
54
55
|
});
|
|
56
|
+
// if preview is in headers, append it to the params
|
|
57
|
+
if (isPreview)
|
|
58
|
+
params.preview = true;
|
|
55
59
|
}
|
|
56
60
|
if ((method === __1.HTTPMethod.POST &&
|
|
57
61
|
(!options.body || typeof options.body === "string")) ||
|
|
@@ -59,13 +63,17 @@ const fetchRequest = () => {
|
|
|
59
63
|
method === __1.HTTPMethod.DELETE) {
|
|
60
64
|
options.headers = Object.assign({ ["Content-Type"]: "application/json" }, options.headers);
|
|
61
65
|
// if output-cache-key is in headers, append it to the body
|
|
62
|
-
const outputCacheKey = options.headers
|
|
63
|
-
options.headers["output-cache-key"];
|
|
66
|
+
const outputCacheKey = options.headers["output-cache-key"];
|
|
64
67
|
if (outputCacheKey) {
|
|
65
68
|
options.body = JSON.stringify(Object.assign(Object.assign({}, (typeof options.body === "string"
|
|
66
69
|
? JSON.parse(options.body || "{}")
|
|
67
70
|
: {})), (outputCacheKey ? { outputCacheKey } : {})));
|
|
68
71
|
}
|
|
72
|
+
if (isPreview) {
|
|
73
|
+
options.body = JSON.stringify(Object.assign(Object.assign({}, (typeof options.body === "string"
|
|
74
|
+
? JSON.parse(options.body || "{}")
|
|
75
|
+
: {})), (isPreview ? { preview: true } : {})));
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
// İstek seçeneklerini oluştur
|
|
71
79
|
const requestOptions = Object.assign(Object.assign({}, options), { method });
|