@aloma.io/integration-sdk 3.0.14 → 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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.14",
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;