roboto-js 1.1.4 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -71,8 +71,14 @@ export default class Roboto{
71
71
  }
72
72
 
73
73
  async registerUser(params){
74
+
75
+ // TODO - need to
76
+
74
77
  return this.api.registerUser(params);
75
78
  }
79
+ async loadUser(params){
80
+ return this.api.loadUser(params);
81
+ }
76
82
  async loadCurrentUser(){
77
83
  return this.api.loadCurrentUser();
78
84
  }
package/src/rbt_api.js CHANGED
@@ -68,7 +68,6 @@ export default class RbtApi {
68
68
  localStorage.setItem('authtoken', response.data.authToken);
69
69
  }
70
70
 
71
-
72
71
  return response.data;
73
72
  } catch (e) {
74
73
 
@@ -118,18 +117,32 @@ export default class RbtApi {
118
117
  User.setData(userData);
119
118
  return User;
120
119
 
121
- //const record = response.data;
122
- //
123
- //if(dataHash){
124
- // record.data = dataHash;
125
- //}
126
- //return new RbtObject(record, this.axios);
127
120
  } catch (e) {
128
121
  return this._handleError(e);
129
122
  }
130
123
 
131
124
  }
132
125
 
126
+ async loadUser(userId){
127
+
128
+ let params = { id: userId };
129
+
130
+ try {
131
+
132
+ const response = await this.axios.post('/user_service/loadUser', [params]);
133
+ let userData = response?.data?.user;
134
+
135
+ let User = new RbtUser({ id: userData.id }, this.axios);
136
+ User.setData(userData);
137
+ return User;
138
+
139
+ } catch (e) {
140
+ return this._handleError(e);
141
+ }
142
+
143
+ }
144
+
145
+
133
146
  async refreshAuthToken(authtoken){
134
147
 
135
148
  try {
@@ -486,7 +499,13 @@ export default class RbtApi {
486
499
 
487
500
  if (_.isObject(err) && _.get(err, 'response')) {
488
501
  const msg = _.get(err, 'response.data.message', 'Error in API response');
489
- throw new Error(msg);
502
+
503
+ if(msg.key){
504
+ throw new Error(msg.key);
505
+ }
506
+ else{
507
+ throw new Error(msg);
508
+ }
490
509
 
491
510
  } else {
492
511
  throw new Error(err.message || 'Unknown error');