@itutoring/itutoring_application_js_api 1.3.34 → 1.3.35

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.
Files changed (2) hide show
  1. package/apiController.js +19 -3
  2. package/package.json +1 -1
package/apiController.js CHANGED
@@ -88,11 +88,19 @@ class APIController
88
88
  {
89
89
  if (request.readyState == 4)
90
90
  {
91
- resolve(request.responseText);
91
+ json = JSON.parse(request.responseText);
92
+ if (json.code ==200)
93
+ {
94
+ resolve(json.data);
95
+ }
96
+ if (json.code == 400)
97
+ {
98
+ resolve("Invalid data");
99
+ }
92
100
  }
93
101
  }
94
102
 
95
- //request.setRequestHeader("Content-Type", "application/json");
103
+ request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
96
104
  request.setRequestHeader("r-key", APIController.#R_KEY);
97
105
  request.setRequestHeader("sites", location.hostname);
98
106
  request.setRequestHeader("key", APIController.#CLIENT_KEY);
@@ -135,7 +143,15 @@ class APIController
135
143
  {
136
144
  if (request.readyState == 4)
137
145
  {
138
- resolve(request.responseText);
146
+ json = JSON.parse(request.responseText);
147
+ if (json.code ==200)
148
+ {
149
+ resolve(json.data);
150
+ }
151
+ if (json.code == 400)
152
+ {
153
+ resolve("Invalid data");
154
+ }
139
155
  }
140
156
  }
141
157
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itutoring/itutoring_application_js_api",
3
- "version": "1.3.34",
3
+ "version": "1.3.35",
4
4
  "description": "Javascript API for iTutoring Application",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",