hamzus-ui 0.0.225 → 0.0.226

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": "hamzus-ui",
3
- "version": "0.0.225",
3
+ "version": "0.0.226",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -7,9 +7,11 @@ export let config = {
7
7
  export function init(options = {
8
8
  url : "http://localhost:8000",
9
9
  sessionTokenName : "token",
10
- requestWithCredentials : false
10
+ requestWithCredentials : false,
11
+ on401:null
11
12
  }) {
12
13
  config.url = options.url || "http://localhost:8000";
13
14
  config.sessionTokenName = options.sessionTokenName || "token";
14
15
  config.requestWithCredentials = options.requestWithCredentials || false;
16
+ config.on401 = options.on401 || null;
15
17
  }
@@ -48,6 +48,10 @@ export function sendRequest(request) {
48
48
  } else if (xhr.status === 400 || xhr.status === 409) {
49
49
  const response = JSON.parse(xhr.responseText)
50
50
  resolve(response)
51
+ } else if (xhr.status === 401) {
52
+ if (config.on401 !== null) {
53
+ config.on401()
54
+ }
51
55
  }
52
56
 
53
57
  resolve(false)