hof 21.0.5-axios-beta → 21.0.7-axios-beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/model/index.js +17 -0
  2. package/package.json +1 -1
package/model/index.js CHANGED
@@ -41,6 +41,7 @@ module.exports = class Model extends EventEmitter {
41
41
  }
42
42
 
43
43
  return this.prepare().then(data => {
44
+ console.log("after prepare promise")
44
45
  data = JSON.stringify(data);
45
46
  const reqConf = this.requestConfig(options);
46
47
  reqConf.method = options.method || 'POST';
@@ -120,6 +121,7 @@ module.exports = class Model extends EventEmitter {
120
121
  return new Promise((resolve, reject) => {
121
122
  const _callback = (err, data, statusCode) => {
122
123
  if (timeoutTimer) {
124
+ console.log("heerrererererer222")
123
125
  clearTimeout(timeoutTimer);
124
126
  timeoutTimer = null;
125
127
  }
@@ -127,8 +129,16 @@ module.exports = class Model extends EventEmitter {
127
129
  const endTime = process.hrtime();
128
130
  const responseTime = timeDiff(startTime, endTime);
129
131
  if (err) {
132
+ console.log("heerrererererer444")
133
+ console.log("d",data)
134
+ console.log("e",err)
135
+ console.log("os", originalSettings)
136
+ console.log("sc", statusCode)
137
+ console.log("rt", responseTime)
138
+ console.log("heerrererererer444")
130
139
  this.emit('fail', err, data, originalSettings, statusCode, responseTime);
131
140
  } else {
141
+ console.log("heerrererererer555")
132
142
  this.emit('success', data, originalSettings, statusCode, responseTime);
133
143
  }
134
144
  if (err) {
@@ -140,13 +150,16 @@ module.exports = class Model extends EventEmitter {
140
150
  console.log("settings---------------: ", settings);
141
151
  this._request(settings)
142
152
  .then(response => {
153
+ console.log("heeeeeeyyy123")
143
154
  return this.handleResponse(response, (error, data, status) => {
155
+ console.log("heeeeeeyyyy912")
144
156
  if (error) {
145
157
  error.headers = response.headers;
146
158
  }
147
159
  _callback(error, data, status);
148
160
  });
149
161
  }).catch(err => {
162
+ console.log("heerrererererer111")
150
163
  if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
151
164
  err.message = 'Connection timed out';
152
165
  err.status = 504;
@@ -164,10 +177,13 @@ module.exports = class Model extends EventEmitter {
164
177
  }
165
178
 
166
179
  handleResponse(response, callback) {
180
+ console.log("handleresponse.....><<>")
167
181
  let data = {};
168
182
  try {
183
+ console.log("TRYhandleresponse.....><<>")
169
184
  data = typeof response.data === 'object' ? response.data : JSON.parse(response.data || '{}');
170
185
  } catch (err) {
186
+ console.log("CATCHhandleresponse.....><<>")
171
187
  err.status = response.status;
172
188
  err.body = response.data;
173
189
  return callback(err, null, response.status);
@@ -189,6 +205,7 @@ module.exports = class Model extends EventEmitter {
189
205
  }
190
206
 
191
207
  prepare() {
208
+ console.log("prepare() promise")
192
209
  return Promise.resolve(this.toJSON());
193
210
  }
194
211
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hof",
3
3
  "description": "A bootstrap for HOF projects",
4
- "version": "21.0.5-axios-beta",
4
+ "version": "21.0.7-axios-beta",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",