nextemos 3.2.3 → 3.3.0

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.
@@ -44,43 +44,42 @@ const fetchRequest = () => {
44
44
  if (method === __1.HTTPMethod.POST)
45
45
  options.headers = Object.assign(Object.assign({}, options.headers), { ['Content-Type']: 'application/json' });
46
46
  logger_1.default.info(`Fetch Request: ${method} - ${apiURL} - ${JSON.stringify(Object.assign({ cache: 'no-cache' }, options))}`);
47
- try {
48
- const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({ cache: 'no-cache' }, options), { method }));
49
- if (!response.ok) {
50
- const errorDetail = yield response.text();
51
- throw new Error(`Fetch Request HTTP Error: ${response.status} - ${apiURL} - ${errorDetail}`);
52
- }
53
- // Headers nesnesini Object'e dönüştürme
54
- const headers = {};
55
- if (response === null || response === void 0 ? void 0 : response.headers) {
56
- response.headers.forEach((value, name) => {
57
- headers[name] = value;
58
- });
59
- }
60
- // response data nesnesini JSON'a dönüştürme.
61
- const responseData = yield response.json().catch(() => ({}));
62
- return {
63
- status: response.status,
64
- data: responseData,
65
- headers
66
- };
47
+ // try {
48
+ const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({ cache: 'no-cache' }, options), { method }));
49
+ if (!response.ok) {
50
+ const errorDetail = yield response.text();
51
+ throw new Error(`Fetch Request HTTP Error: ${response.status} - ${apiURL} - ${errorDetail}`);
67
52
  }
68
- catch (error) {
69
- if (error instanceof Error) {
70
- logger_1.default.fatal(`Fetch Request Exception Error! -> ${apiURL} -> ${error.name} : ${error.message}`);
71
- return {
72
- status: 500,
73
- error: error.name,
74
- errorMessage: error.message
75
- };
76
- }
77
- logger_1.default.fatal(`Fetch Request Exception Unknown Error! ->`, error);
78
- return {
79
- status: 500,
80
- error: `${error}`,
81
- errorMessage: `${error}`
82
- };
53
+ // Headers nesnesini Object'e dönüştürme
54
+ const headers = {};
55
+ if (response === null || response === void 0 ? void 0 : response.headers) {
56
+ response.headers.forEach((value, name) => {
57
+ headers[name] = value;
58
+ });
83
59
  }
60
+ // response data nesnesini JSON'a dönüştürme.
61
+ const responseData = yield response.json().catch(() => ({}));
62
+ return {
63
+ status: response.status,
64
+ data: responseData,
65
+ headers
66
+ };
67
+ // } catch (error) {
68
+ // if (error instanceof Error) {
69
+ // logger.fatal(`Fetch Request Exception Error! -> ${apiURL} -> ${error.name} : ${error.message}`);
70
+ // return {
71
+ // status: 500,
72
+ // error: error.name,
73
+ // errorMessage: error.message
74
+ // };
75
+ // }
76
+ // logger.fatal(`Fetch Request Exception Unknown Error! ->`, error);
77
+ // return {
78
+ // status: 500,
79
+ // error: `${error}`,
80
+ // errorMessage: `${error}`
81
+ // };
82
+ // }
84
83
  });
85
84
  /**
86
85
  * GET isteği yapar.
@@ -75,11 +75,11 @@ export interface IResponse {
75
75
  /**
76
76
  * API isteğinin başarılı olup olmadığını belirtir (true: başarılı, false: başarısız).
77
77
  */
78
- isSuccess: boolean;
78
+ isSuccess: boolean | number;
79
79
  /**
80
80
  * API yanıtının durum kodunu temsil eden bir dize. Bu, belirli başarı veya hata kodlarını iletmek için kullanılabilir.
81
81
  */
82
- statusCode: string;
82
+ statusCode: string | number;
83
83
  /**
84
84
  * Yanıt hakkında ek bilgiler sağlayan bir mesaj. Bu, hata mesajları veya başarı teyitleri için kullanılabilir.
85
85
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextemos",
3
- "version": "3.2.3",
3
+ "version": "3.3.0",
4
4
  "description": "For helpers and hooks used in NextJS projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",