whio-api-sdk 1.0.13 → 1.0.151

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.
@@ -6,6 +6,7 @@ export declare class ApiSDK {
6
6
  private refreshToken;
7
7
  private user;
8
8
  constructor(config?: SDKConfig);
9
+ private getToken;
9
10
  private initialize;
10
11
  private request;
11
12
  private fileUploadRequest;
@@ -23,6 +23,14 @@ export class ApiSDK {
23
23
  };
24
24
  this.initialize();
25
25
  }
26
+ getToken() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ this.accessToken = yield this.storage.getItem('access_token');
29
+ if (!this.accessToken) {
30
+ throw new Error('Access token not found');
31
+ }
32
+ });
33
+ }
26
34
  initialize() {
27
35
  return __awaiter(this, void 0, void 0, function* () {
28
36
  this.accessToken = yield this.storage.getItem('access_token');
@@ -37,6 +45,8 @@ export class ApiSDK {
37
45
  'Content-Type': 'application/json',
38
46
  'ngrok-skip-browser-warning': 'true'
39
47
  };
48
+ yield this.getToken();
49
+ console.log(this.accessToken);
40
50
  if (this.accessToken) {
41
51
  defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
42
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.151",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/src/sdk/sdk.ts CHANGED
@@ -46,6 +46,13 @@ export class ApiSDK {
46
46
  this.initialize();
47
47
  }
48
48
 
49
+ private async getToken() {
50
+ this.accessToken = await this.storage!.getItem('access_token');
51
+ if (!this.accessToken) {
52
+ throw new Error('Access token not found');
53
+ }
54
+ }
55
+
49
56
  private async initialize() {
50
57
  this.accessToken = await this.storage!.getItem('access_token');
51
58
  const userString = await this.storage!.getItem('user');
@@ -64,6 +71,10 @@ export class ApiSDK {
64
71
  'ngrok-skip-browser-warning': 'true'
65
72
  };
66
73
 
74
+ await this.getToken();
75
+
76
+ console.log(this.accessToken);
77
+
67
78
  if (this.accessToken) {
68
79
  defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
69
80
  }