hof 21.0.5-axios-beta → 21.0.6-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 +11 -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,10 @@ 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")
130
133
  this.emit('fail', err, data, originalSettings, statusCode, responseTime);
131
134
  } else {
135
+ console.log("heerrererererer555")
132
136
  this.emit('success', data, originalSettings, statusCode, responseTime);
133
137
  }
134
138
  if (err) {
@@ -140,13 +144,16 @@ module.exports = class Model extends EventEmitter {
140
144
  console.log("settings---------------: ", settings);
141
145
  this._request(settings)
142
146
  .then(response => {
147
+ console.log("heeeeeeyyy123")
143
148
  return this.handleResponse(response, (error, data, status) => {
149
+ console.log("heeeeeeyyyy912")
144
150
  if (error) {
145
151
  error.headers = response.headers;
146
152
  }
147
153
  _callback(error, data, status);
148
154
  });
149
155
  }).catch(err => {
156
+ console.log("heerrererererer111")
150
157
  if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
151
158
  err.message = 'Connection timed out';
152
159
  err.status = 504;
@@ -164,10 +171,13 @@ module.exports = class Model extends EventEmitter {
164
171
  }
165
172
 
166
173
  handleResponse(response, callback) {
174
+ console.log("handleresponse.....><<>")
167
175
  let data = {};
168
176
  try {
177
+ console.log("TRYhandleresponse.....><<>")
169
178
  data = typeof response.data === 'object' ? response.data : JSON.parse(response.data || '{}');
170
179
  } catch (err) {
180
+ console.log("CATCHhandleresponse.....><<>")
171
181
  err.status = response.status;
172
182
  err.body = response.data;
173
183
  return callback(err, null, response.status);
@@ -189,6 +199,7 @@ module.exports = class Model extends EventEmitter {
189
199
  }
190
200
 
191
201
  prepare() {
202
+ console.log("prepare() promise")
192
203
  return Promise.resolve(this.toJSON());
193
204
  }
194
205
 
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.6-axios-beta",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",