@verii/http-client 1.1.0-pre.1763452964 → 1.1.0-pre.1764065131

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/client.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verii/http-client",
3
- "version": "1.1.0-pre.1763452964",
3
+ "version": "1.1.0-pre.1764065131",
4
4
  "description": "HTTP client for Verii network",
5
5
  "repository": "https://github.com/LFDT-Verii/core",
6
6
  "main": "index.js",
@@ -42,5 +42,5 @@
42
42
  "lib"
43
43
  ]
44
44
  },
45
- "gitHead": "18943a1a15dc61b19d05b8ec0b0112234817e1dc"
45
+ "gitHead": "22f75261bf2f5fca4d48f4a5473e243a3f5e68e8"
46
46
  }
package/src/client.js CHANGED
@@ -175,7 +175,10 @@ const initHttpClient = (options) => {
175
175
  post: (url, payload, reqOptions) =>
176
176
  request(
177
177
  url,
178
- reqOptions,
178
+ {
179
+ ...reqOptions,
180
+ headers: setContentType(reqOptions?.headers || {}, payload),
181
+ },
179
182
  HTTP_VERBS.POST,
180
183
  host,
181
184
  context,
@@ -188,6 +191,14 @@ const initHttpClient = (options) => {
188
191
  };
189
192
  };
190
193
 
194
+ const setContentType = (headers, payload) => {
195
+ if (isObject(payload) && !headers['content-type']) {
196
+ return { ...headers, 'content-type': 'application/json' };
197
+ }
198
+
199
+ return headers;
200
+ };
201
+
191
202
  const parseOptions = (options) => {
192
203
  const clientOptions = {
193
204
  connect: {