@autofleet/network 1.4.8-beta.0 → 1.4.8
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.
- package/index.js +20 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -38,7 +38,6 @@ const defaultSettings = {
|
|
|
38
38
|
shouldResetTimeout: true,
|
|
39
39
|
},
|
|
40
40
|
keepAlive: true,
|
|
41
|
-
enableHttpLogs: true,
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
const createRequestString = (request) => `[${(request.method || '').toUpperCase()}] ${request.baseURL}${request.url}`;
|
|
@@ -69,9 +68,7 @@ module.exports = class Network {
|
|
|
69
68
|
this.axios = settings.cache ? setup(this.settings) : axios.create(this.settings);
|
|
70
69
|
this.addRetry(settings);
|
|
71
70
|
this.buildClassHttpMethods();
|
|
72
|
-
|
|
73
|
-
this.addLogs();
|
|
74
|
-
}
|
|
71
|
+
this.addLogs();
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
addRetry(settings) {
|
|
@@ -164,4 +161,23 @@ module.exports = class Network {
|
|
|
164
161
|
|
|
165
162
|
return currentResult;
|
|
166
163
|
}
|
|
164
|
+
|
|
165
|
+
async getAllPagesFromQueryEndpoint(url, options = {}) {
|
|
166
|
+
let currentResult = [];
|
|
167
|
+
|
|
168
|
+
let moreResultsToLoad = true;
|
|
169
|
+
let page = 1;
|
|
170
|
+
while(moreResultsToLoad && page < 100) {
|
|
171
|
+
const { data } = await this.post(url, {
|
|
172
|
+
...options,
|
|
173
|
+
page: page,
|
|
174
|
+
});
|
|
175
|
+
const { rows, count } = data;
|
|
176
|
+
page += 1;
|
|
177
|
+
currentResult = currentResult.concat(rows);
|
|
178
|
+
moreResultsToLoad = currentResult.length < count;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return currentResult;
|
|
182
|
+
}
|
|
167
183
|
};
|