hof 21.0.4-axios-beta → 21.0.6-axios-beta
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,6 @@ const url = require('url');
|
|
4
4
|
module.exports = (settings, body) => {
|
5
5
|
return Object.assign({}, settings, {
|
6
6
|
'url' : settings.uri || settings.url || url.format(settings),
|
7
|
-
'data': settings.body || body || settings.data
|
8
|
-
'responseType': 'arraybuffer'
|
7
|
+
'data': settings.body || body || settings.data
|
9
8
|
});
|
10
9
|
}
|
@@ -9,7 +9,8 @@ module.exports = class PDFModel extends Model {
|
|
9
9
|
const settings = super.requestConfig(options);
|
10
10
|
settings.encoding = null;
|
11
11
|
settings.rejectUnauthorized = false;
|
12
|
-
|
12
|
+
settings.responseType = 'arraybuffer';
|
13
|
+
console.log("settings------+_+_+_+_---------: ", settings);
|
13
14
|
return settings;
|
14
15
|
}
|
15
16
|
|
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
|
|