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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.371",
3
+ "version": "0.0.374",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -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) => {