@veritree/services 2.0.0 → 2.1.1
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/helpers/api.js +18 -6
package/package.json
CHANGED
package/src/helpers/api.js
CHANGED
|
@@ -26,7 +26,7 @@ function addVersionArg(url) {
|
|
|
26
26
|
*/
|
|
27
27
|
function getConfig(method, data, as) {
|
|
28
28
|
const isGet = method === "get";
|
|
29
|
-
const isSpoofing = as
|
|
29
|
+
const isSpoofing = as;
|
|
30
30
|
const isFormData = data instanceof FormData;
|
|
31
31
|
const accessToken = `Bearer ${getCookie("access_token")}`;
|
|
32
32
|
|
|
@@ -134,7 +134,9 @@ export default class Api {
|
|
|
134
134
|
* @returns {promise}
|
|
135
135
|
*/
|
|
136
136
|
async post(url, data, as, args) {
|
|
137
|
+
// console.log(args);
|
|
137
138
|
if (!url) url = `${this.getUrl()}${this.getUrlParams(args)}`;
|
|
139
|
+
console.log(url);
|
|
138
140
|
return await this.unWrap(url, "post", data, as);
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -158,15 +160,25 @@ export default class Api {
|
|
|
158
160
|
getUrlParams(args) {
|
|
159
161
|
this.setOrg();
|
|
160
162
|
let isOrgLess = false;
|
|
161
|
-
let
|
|
162
|
-
let
|
|
163
|
+
let isOrgAs = false;
|
|
164
|
+
let orgIdParam = null;
|
|
165
|
+
let orgTypeParam = null;
|
|
163
166
|
|
|
164
167
|
// while most of endpoints require an org id and type, some endpoints do not
|
|
165
|
-
if (args
|
|
166
|
-
isOrgLess = Object.
|
|
168
|
+
if (args) {
|
|
169
|
+
isOrgLess = Object.hasOwn(args, "orgless");
|
|
170
|
+
isOrgAs = Object.hasOwn(args, "org_id_as") && Object.hasOwn(args, "org_type_as");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// a super admin user can create/edit data from other orgs
|
|
174
|
+
// and for that, we can't use the org id and type in
|
|
175
|
+
// the session.
|
|
176
|
+
if(isOrgAs) {
|
|
177
|
+
orgIdParam = `org_id=${args.org_id_as}`;
|
|
178
|
+
orgTypeParam = `&org_type=${args.org_type_as}`;
|
|
167
179
|
}
|
|
168
180
|
|
|
169
|
-
if (!isOrgLess) {
|
|
181
|
+
if (!isOrgLess && !isOrgAs) {
|
|
170
182
|
if (this.orgId) orgIdParam = `org_id=${this.orgId}`;
|
|
171
183
|
if (this.orgType) orgTypeParam = `&org_type=${this.orgType}`;
|
|
172
184
|
}
|