@aloma.io/integration-sdk 3.0.13 → 3.0.15

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.
@@ -62,6 +62,21 @@ class Fetcher {
62
62
  try {
63
63
  await local.customize(options, args);
64
64
  console.log(options, args);
65
+ if (!options?.headers || !options?.headers?.Accept) {
66
+ options.headers = {
67
+ ...options.headers,
68
+ Accept: 'application/json'
69
+ };
70
+ }
71
+ if (!options?.headers || !options?.headers?.['Content-type']) {
72
+ options.headers = {
73
+ ...options.headers,
74
+ 'Content-type': 'application/json'
75
+ };
76
+ }
77
+ if (!(options?.method === 'GET' || options?.method === 'HEAD') && options?.body && !(typeof (options.body) === 'string') && options?.headers?.['Content-type'] === 'application/json') {
78
+ options.body = JSON.stringify(options.body);
79
+ }
65
80
  const ret = await fetch(theURL, options);
66
81
  const status = await ret.status;
67
82
  if (status > 399) {
@@ -74,7 +89,7 @@ class Fetcher {
74
89
  }
75
90
  catch (e) {
76
91
  --retries;
77
- console.log(theURL, e, this);
92
+ console.log(theURL, e);
78
93
  if (retries <= 0)
79
94
  throw e;
80
95
  return local.onError(e, url, options, retries, args);
@@ -123,7 +138,6 @@ class OAuthFetcher extends Fetcher {
123
138
  async customize(options, args = {}) {
124
139
  const local = this;
125
140
  const token = await local.getToken(args.forceTokenRefresh);
126
- options = { ...options };
127
141
  options.headers = {
128
142
  ...options.headers,
129
143
  Authorization: `Bearer ${token}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -80,6 +80,27 @@ class Fetcher {
80
80
  await local.customize(options, args);
81
81
 
82
82
  console.log(options, args);
83
+
84
+ if (!options?.headers || !options?.headers?.Accept)
85
+ {
86
+ options.headers = {
87
+ ...options.headers,
88
+ Accept: 'application/json'
89
+ }
90
+ }
91
+
92
+ if (!options?.headers || !options?.headers?.['Content-type'])
93
+ {
94
+ options.headers = {
95
+ ...options.headers,
96
+ 'Content-type': 'application/json'
97
+ }
98
+ }
99
+
100
+ if (!(options?.method === 'GET' || options?.method === 'HEAD') && options?.body && !(typeof(options.body) === 'string') && options?.headers?.['Content-type'] === 'application/json')
101
+ {
102
+ options.body = JSON.stringify(options.body)
103
+ }
83
104
 
84
105
  const ret = await fetch(theURL, options);
85
106
  const status = await ret.status;