@andersonalmeidax0/webcomponents 0.1.4 → 0.1.6

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/RestAPIAdapter.js CHANGED
@@ -14,7 +14,7 @@ import {PlatAPIError,PlatAPIReturnCodeError,PlatAPIAuthError,PlatAPIDBNotFound,P
14
14
  //https://docs.oracle.com/en/cloud/saas/marketing/eloqua-rest-api/op-api-rest-1.0-data-account-post.html
15
15
 
16
16
 
17
- var DEBUG_APIFETCH=true;
17
+ //var DEBUG_APIFETCH=true;
18
18
 
19
19
  //TODO:
20
20
  //1-tem que usar heranca para metodos new, validate, etc
@@ -81,10 +81,11 @@ function getStorageWithExpiry(key) {
81
81
  urlServer;
82
82
  tagData;
83
83
  /** ***********************
84
- *
84
+ * tableName is entity (after server)
85
+ * Server is option (can be null for local API ou not for remote APIs)
85
86
  *********************** */
86
- constructor(tableName,urlServer,tagData,token,pnewVO) {
87
-
87
+ constructor(tableName,urlServer,tagData,token,pnewVO,debug) {
88
+ this.DEBUG_APIFETCH=debug;
88
89
  this.tableName=tableName;
89
90
  this.urlServer=urlServer;
90
91
  this.tagData=tagData;
@@ -118,7 +119,7 @@ function getStorageWithExpiry(key) {
118
119
  async getJSONResponse(response) {
119
120
  var r=null;
120
121
  r=await response.json();
121
- if(DEBUG_APIFETCH)alert(JSON.stringify(r,null,2));
122
+ if(this.DEBUG_APIFETCH)alert(JSON.stringify(r,null,2));
122
123
  if(r.error)
123
124
  throw new PlatAPIReturnCodeError(r.error.message);
124
125
  return r;
@@ -132,8 +133,10 @@ function getStorageWithExpiry(key) {
132
133
  //if(ptoken==null)
133
134
  // throw new PlatAPIAuthError( `An error has occured: ${response.status}`);
134
135
 
135
- var {method,url,body}=this.getParams(q,vo,this.urlServer+"/"+this.tableName,filter);
136
-
136
+ var {method,url,body}=this.getParams(q,vo,"/"+this.tableName,filter);
137
+ //server is optional
138
+ url = this.urlServer==null?url:this.urlServer+url;
139
+
137
140
  const response = await this.myFetch3(ptoken,url,method,body);
138
141
  if (!response.ok) {
139
142
  if(response.status===404)
@@ -182,10 +185,10 @@ function getStorageWithExpiry(key) {
182
185
  *
183
186
  *********************** */
184
187
  async myFetch3 (token,url,method,body) {
185
- if(DEBUG_APIFETCH)alert("url:"+url);
186
- if(DEBUG_APIFETCH)alert("m:"+method);
187
- if(DEBUG_APIFETCH)alert("body:"+body);
188
- if(DEBUG_APIFETCH)alert("token:"+JSON.stringify(token));
188
+ if(this.DEBUG_APIFETCH)alert("url:"+url);
189
+ if(this.DEBUG_APIFETCH)alert("m:"+method);
190
+ if(this.DEBUG_APIFETCH)alert("body:"+body);
191
+ if(this.DEBUG_APIFETCH)alert("token:"+JSON.stringify(token));
189
192
 
190
193
  var r = await fetch(url,
191
194
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andersonalmeidax0/webcomponents",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "webcomponents",
5
5
  "main": "webcomponents",
6
6
  "scripts": {
package/releasenotes.txt CHANGED
@@ -3,6 +3,7 @@
3
3
  0.1.2: with text labels for buttons
4
4
  0.1.3: RestAPIAdapter init
5
5
  0.1.4: Error move to root
6
+ 0.1.6: url correct, debug
6
7
 
7
8
 
8
9
  TODO