playov2-js-utilities 0.3.60 → 0.3.61

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.
@@ -21,6 +21,16 @@ const Logger = require('../logger.js');
21
21
  * @returns
22
22
  */
23
23
  const playoResponseHandler = (resp, requestId) => {
24
+
25
+ if(!resp) {
26
+ resp = {
27
+ isAxiosError: true,
28
+ code: "NO_RESPONSE",
29
+ message: "No response from the service",
30
+ data : {requestStatus: 0}
31
+ }
32
+ }
33
+
24
34
  if (resp.isAxiosError) {
25
35
  //if axios error is triggered then axios throws HTTP code for timeout or other forms of unsuccessful errors
26
36
  const {
@@ -74,7 +84,7 @@ const get = async (url, headers = {}, query = {}, requestId = '', responseHandle
74
84
  const resp = await Axios.get(url, { headers, params: query, timeout });
75
85
  return responseHandler(resp, requestId, apiName);
76
86
  } catch (error) {
77
- Logger.prepareErrorLog(requestId, { url, headers, query, data: error.response }, `Api call to url to ${url} failed!`);
87
+ Logger.prepareErrorLog(requestId, { url, headers, query }, `Api call to url to ${url} failed!`);
78
88
  return responseHandler(error.response, requestId, apiName);
79
89
  }
80
90
  };
@@ -96,7 +106,7 @@ const post = async (url, headers = {}, query = {}, body = {}, requestId = '', re
96
106
  const resp = await Axios.post(url, body, options);
97
107
  return responseHandler(resp, requestId, apiName);
98
108
  } catch (error) {
99
- Logger.prepareErrorLog(requestId, { url, headers, query, body, data: error.response.data }, `Api call to url to ${url} failed due to ${error.response.message}`);
109
+ Logger.prepareErrorLog(requestId, { url, headers, query, body }, `Api call to url to ${url} failed due to ${error.response.message}`);
100
110
  return responseHandler(error.response, requestId, apiName);
101
111
  }
102
112
  };
@@ -118,7 +128,7 @@ const put = async (url, headers = {}, query = {}, body = {}, requestId = '', res
118
128
  const resp = await Axios.put(url, body, options);
119
129
  return responseHandler(resp, requestId, apiName);
120
130
  } catch (error) {
121
- Logger.prepareErrorLog(requestId, { url, headers, query, body, data: error.response.data }, `Api call to url to ${url} failed due to ${error.response.message}`);
131
+ Logger.prepareErrorLog(requestId, { url, headers, query, body }, `Api call to url to ${url} failed due to ${error.response.message}`);
122
132
  return responseHandler(error.response, requestId, apiName);
123
133
  }
124
134
  };
@@ -140,7 +150,7 @@ const remove = async (url, headers = {}, query = {}, body, requestId = '', respo
140
150
  const resp = await Axios.delete(url, options);
141
151
  return responseHandler(resp, requestId);
142
152
  } catch (error) {
143
- Logger.prepareErrorLog(requestId, { url, headers, query, body, data: error.response.data }, `Api call to url to ${url} failed due to ${error.response.message}`);
153
+ Logger.prepareErrorLog(requestId, { url, headers, query, body }, `Api call to url to ${url} failed due to ${error.response.message}`);
144
154
  return responseHandler(error.response, requestId, apiName);
145
155
  }
146
156
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playov2-js-utilities",
3
- "version": "0.3.60",
3
+ "version": "0.3.61",
4
4
  "description": "Private package for JS utility functions",
5
5
  "main": "index.js",
6
6
  "scripts": {