nextemos 2.2.6 → 2.2.7
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.
|
@@ -35,9 +35,10 @@ const fetchRequest = () => {
|
|
|
35
35
|
const request = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
var { url, method, params } = _a, options = __rest(_a, ["url", "method", "params"]);
|
|
37
37
|
const apiURL = new URL(url); // url'nin zaten apiUrl ve apiVersion içerdiği varsayılıyor
|
|
38
|
-
if (params)
|
|
38
|
+
if (params)
|
|
39
39
|
Object.keys(params).forEach(key => apiURL.searchParams.append(key, params[key]));
|
|
40
|
-
|
|
40
|
+
if (method === __1.HTTPMethod.POST)
|
|
41
|
+
options.headers = Object.assign(Object.assign({}, options.headers), { ['Content-Type']: 'application/json' });
|
|
41
42
|
try {
|
|
42
43
|
const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({}, options), { method }));
|
|
43
44
|
// Headers nesnesini Object'e dönüştürme
|
|
@@ -49,7 +50,7 @@ const fetchRequest = () => {
|
|
|
49
50
|
if (!response.ok) {
|
|
50
51
|
const errorMessage = (responseData === null || responseData === void 0 ? void 0 : responseData.message) || 'Bir şeyler yanlış gitti!';
|
|
51
52
|
console.error(`Hata: ${response.status} - ${errorMessage}`);
|
|
52
|
-
return { status: response.status, error: errorMessage };
|
|
53
|
+
return { status: response.status, error: errorMessage, headers };
|
|
53
54
|
}
|
|
54
55
|
return { status: response.status, data: responseData, headers };
|
|
55
56
|
}
|