@karpeleslab/klbfw 0.1.4 → 0.1.7
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/internal.js +1 -1
- package/package.json +1 -1
- package/rest.js +19 -7
package/internal.js
CHANGED
|
@@ -43,7 +43,7 @@ function rest_url(path, with_token, context) {
|
|
|
43
43
|
if (fwWrapper.getCallUrlPrefix()) call_url = fwWrapper.getCallUrlPrefix() + call_url;
|
|
44
44
|
|
|
45
45
|
// copy context, proceed with overload then add to url
|
|
46
|
-
var ctx_final = fwWrapper.getContext();
|
|
46
|
+
var ctx_final = Object.assign({}, fwWrapper.getContext());
|
|
47
47
|
for (var i in context) ctx_final[i] = context[i];
|
|
48
48
|
for (var i in ctx_final) {
|
|
49
49
|
if (i == "_") continue;
|
package/package.json
CHANGED
package/rest.js
CHANGED
|
@@ -2,18 +2,26 @@
|
|
|
2
2
|
// vim: et:ts=4:sw=4
|
|
3
3
|
|
|
4
4
|
const internal = require('./internal');
|
|
5
|
+
const fwWrapper = require('./fw-wrapper');
|
|
5
6
|
|
|
6
7
|
module.exports.rest = (name, verb, params, context) => {
|
|
7
8
|
if (typeof __platformAsyncRest !== "undefined") {
|
|
8
|
-
|
|
9
|
+
context = context || {};
|
|
10
|
+
var ctx_final = Object.assign({}, fwWrapper.getContext());
|
|
11
|
+
for (var i in context) ctx_final[i] = context[i];
|
|
12
|
+
return __platformAsyncRest(name, verb, params, ctx_final);
|
|
9
13
|
}
|
|
10
14
|
if (typeof __platformRest !== "undefined") {
|
|
11
15
|
// direct SSR-mode call to rest api
|
|
12
16
|
return new Promise(function(resolve, reject) {
|
|
13
17
|
__platformRest(name, verb, params, function(res, err) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
if (err) {
|
|
19
|
+
reject(err);
|
|
20
|
+
} else if (res.result != "success") {
|
|
21
|
+
reject(res);
|
|
22
|
+
} else {
|
|
23
|
+
resolve(res);
|
|
24
|
+
}
|
|
17
25
|
});
|
|
18
26
|
});
|
|
19
27
|
}
|
|
@@ -49,9 +57,13 @@ module.exports.rest_get = (name, params) => {
|
|
|
49
57
|
// direct SSR-mode call to rest api
|
|
50
58
|
return new Promise(function(resolve, reject) {
|
|
51
59
|
__platformRest(name, "GET", params, function(res, err) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
if (err) {
|
|
61
|
+
reject(err);
|
|
62
|
+
} else if (res.result != "success") {
|
|
63
|
+
reject(res);
|
|
64
|
+
} else {
|
|
65
|
+
resolve(res);
|
|
66
|
+
}
|
|
55
67
|
});
|
|
56
68
|
});
|
|
57
69
|
}
|