@less-is-more/less-js 1.3.2 → 1.3.3
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/package.json +1 -1
- package/src/service.js +8 -7
package/package.json
CHANGED
package/src/service.js
CHANGED
|
@@ -14,14 +14,15 @@ module.exports = class Service {
|
|
|
14
14
|
"http://SERVICE" + (this.#isTest ? ".test" : ".prod") + "." + domain;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
static setDelay(async = false,
|
|
17
|
+
static setDelay(async = false, asyncDelaySecond = 0) {
|
|
18
18
|
let headers = {};
|
|
19
19
|
if (async) {
|
|
20
20
|
headers["X-Fc-Invocation-Type"] = "Async";
|
|
21
21
|
}
|
|
22
|
-
if (
|
|
23
|
-
headers["x-fc-async-delay"] =
|
|
22
|
+
if (asyncDelaySecond > 0) {
|
|
23
|
+
headers["x-fc-async-delay"] = asyncDelaySecond;
|
|
24
24
|
}
|
|
25
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
25
26
|
return headers;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -30,14 +31,14 @@ module.exports = class Service {
|
|
|
30
31
|
path,
|
|
31
32
|
params,
|
|
32
33
|
async = false,
|
|
33
|
-
|
|
34
|
+
asyncDelaySecond = 0
|
|
34
35
|
) {
|
|
35
36
|
let url = this.#urlPrefix.replace("SERVICE", serviceName) + path;
|
|
36
37
|
try {
|
|
37
38
|
if (params) {
|
|
38
39
|
url += "?" + qs.stringify(params);
|
|
39
40
|
}
|
|
40
|
-
const headers = this.setDelay(async,
|
|
41
|
+
const headers = this.setDelay(async, asyncDelaySecond);
|
|
41
42
|
const result = await axios.get(url, { headers });
|
|
42
43
|
return result.data;
|
|
43
44
|
} catch (e) {
|
|
@@ -51,11 +52,11 @@ module.exports = class Service {
|
|
|
51
52
|
path,
|
|
52
53
|
params = {},
|
|
53
54
|
async = false,
|
|
54
|
-
|
|
55
|
+
asyncDelaySecond = 0
|
|
55
56
|
) {
|
|
56
57
|
let url = this.#urlPrefix.replace("SERVICE", serviceName) + path;
|
|
57
58
|
try {
|
|
58
|
-
const headers = this.setDelay(async,
|
|
59
|
+
const headers = this.setDelay(async, asyncDelaySecond);
|
|
59
60
|
const result = await axios.post(url, qs.stringify(params), {
|
|
60
61
|
headers,
|
|
61
62
|
});
|