hof 21.0.7-axios-beta → 21.0.9-axios-beta
Sign up to get free protection for your applications and to get access to all the features.
- package/model/index.js +8 -18
- package/package.json +1 -1
package/model/index.js
CHANGED
@@ -41,13 +41,13 @@ module.exports = class Model extends EventEmitter {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
return this.prepare().then(data => {
|
44
|
-
console.log("after prepare promise")
|
45
44
|
data = JSON.stringify(data);
|
46
45
|
const reqConf = this.requestConfig(options);
|
47
46
|
reqConf.method = options.method || 'POST';
|
48
47
|
|
49
48
|
reqConf.headers = Object.assign({
|
50
49
|
'Content-Type': 'application/json',
|
50
|
+
'User-Agent': 'Axios 0.25.0',
|
51
51
|
'Content-Length': Buffer.byteLength(data)
|
52
52
|
}, reqConf.headers || {});
|
53
53
|
return this.request(reqConf, data, callback);
|
@@ -121,7 +121,6 @@ module.exports = class Model extends EventEmitter {
|
|
121
121
|
return new Promise((resolve, reject) => {
|
122
122
|
const _callback = (err, data, statusCode) => {
|
123
123
|
if (timeoutTimer) {
|
124
|
-
console.log("heerrererererer222")
|
125
124
|
clearTimeout(timeoutTimer);
|
126
125
|
timeoutTimer = null;
|
127
126
|
}
|
@@ -129,37 +128,32 @@ module.exports = class Model extends EventEmitter {
|
|
129
128
|
const endTime = process.hrtime();
|
130
129
|
const responseTime = timeDiff(startTime, endTime);
|
131
130
|
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")
|
139
131
|
this.emit('fail', err, data, originalSettings, statusCode, responseTime);
|
140
132
|
} else {
|
141
|
-
console.log("
|
133
|
+
console.log("SUCCESS>>>>>>>>>>>>>>>")
|
142
134
|
this.emit('success', data, originalSettings, statusCode, responseTime);
|
143
135
|
}
|
136
|
+
console.log("*****ERRR********")
|
137
|
+
console.log(err)
|
138
|
+
console.log("*****ERRR********")
|
144
139
|
if (err) {
|
140
|
+
console.log("err11")
|
141
|
+
console.log(err)
|
142
|
+
console.log("err11")
|
145
143
|
reject(err);
|
146
144
|
} else {
|
147
145
|
resolve(data);
|
148
146
|
}
|
149
147
|
};
|
150
|
-
console.log("settings---------------: ", settings);
|
151
148
|
this._request(settings)
|
152
149
|
.then(response => {
|
153
|
-
console.log("heeeeeeyyy123")
|
154
150
|
return this.handleResponse(response, (error, data, status) => {
|
155
|
-
console.log("heeeeeeyyyy912")
|
156
151
|
if (error) {
|
157
152
|
error.headers = response.headers;
|
158
153
|
}
|
159
154
|
_callback(error, data, status);
|
160
155
|
});
|
161
156
|
}).catch(err => {
|
162
|
-
console.log("heerrererererer111")
|
163
157
|
if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
|
164
158
|
err.message = 'Connection timed out';
|
165
159
|
err.status = 504;
|
@@ -177,13 +171,10 @@ module.exports = class Model extends EventEmitter {
|
|
177
171
|
}
|
178
172
|
|
179
173
|
handleResponse(response, callback) {
|
180
|
-
console.log("handleresponse.....><<>")
|
181
174
|
let data = {};
|
182
175
|
try {
|
183
|
-
console.log("TRYhandleresponse.....><<>")
|
184
176
|
data = typeof response.data === 'object' ? response.data : JSON.parse(response.data || '{}');
|
185
177
|
} catch (err) {
|
186
|
-
console.log("CATCHhandleresponse.....><<>")
|
187
178
|
err.status = response.status;
|
188
179
|
err.body = response.data;
|
189
180
|
return callback(err, null, response.status);
|
@@ -205,7 +196,6 @@ module.exports = class Model extends EventEmitter {
|
|
205
196
|
}
|
206
197
|
|
207
198
|
prepare() {
|
208
|
-
console.log("prepare() promise")
|
209
199
|
return Promise.resolve(this.toJSON());
|
210
200
|
}
|
211
201
|
|