ywana-core8 0.0.371 → 0.0.374
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/dist/index.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +10 -3
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +10 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/http/client.js +14 -3
package/package.json
CHANGED
package/src/http/client.js
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
async function fetchAsync(method, URL, body = null, token) {
|
1
|
+
async function fetchAsync(method, URL, body = null, token, headers) {
|
2
2
|
|
3
3
|
console.log('FETCH', method, URL)
|
4
4
|
|
5
|
+
|
6
|
+
const requestHeaders = Object.assign({}, {
|
7
|
+
"Accept": "application/json",
|
8
|
+
"Content-Type": "application/json",
|
9
|
+
"x-access-token": token
|
10
|
+
}, headers)
|
11
|
+
|
5
12
|
const request = {
|
6
13
|
method,
|
7
14
|
mode: 'cors',
|
@@ -13,6 +20,10 @@ async function fetchAsync(method, URL, body = null, token) {
|
|
13
20
|
body
|
14
21
|
}
|
15
22
|
|
23
|
+
console.log("HTTP Client", request)
|
24
|
+
|
25
|
+
if (headers) request.headers = request.headers
|
26
|
+
|
16
27
|
try {
|
17
28
|
var response = await fetch(URL, request);
|
18
29
|
if (response.ok) {
|
@@ -39,9 +50,9 @@ export const HTTPClient = (domain, securityCtx) => {
|
|
39
50
|
return fetchAsync('GET', domain + URL, undefined, token);
|
40
51
|
},
|
41
52
|
|
42
|
-
POST: (URL, body) => {
|
53
|
+
POST: (URL, body, headers) => {
|
43
54
|
const token = securityCtx ? securityCtx.token() : null;
|
44
|
-
return fetchAsync('POST', domain + URL, body, token);
|
55
|
+
return fetchAsync('POST', domain + URL, body, token, headers);
|
45
56
|
},
|
46
57
|
|
47
58
|
PUT: (URL, body) => {
|