nextemos 3.3.0 → 3.3.1

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,42 +44,43 @@ 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}`);
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
+ };
52
67
  }
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
- });
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
+ };
59
83
  }
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
- // }
83
84
  });
84
85
  /**
85
86
  * GET isteği yapar.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextemos",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "For helpers and hooks used in NextJS projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",