@faasjs/request 1.3.2 → 1.4.0

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.js CHANGED
@@ -168,7 +168,7 @@ async function request(url$1, options = { headers: {} }) {
168
168
  response.statusMessage = res.statusMessage;
169
169
  response.headers = res.headers;
170
170
  response.body = data;
171
- if (response.body && response.headers["content-type"] && response.headers["content-type"].includes("application/json"))
171
+ if (response.body && response.headers["content-type"] && response.headers["content-type"].includes("application/json") && typeof response.body === "string" && (response.body.startsWith("{") || response.body.startsWith("[")))
172
172
  try {
173
173
  response.body = (options.parse || JSON.parse)(response.body);
174
174
  logger$1.debug("response.parse JSON");
package/dist/index.mjs CHANGED
@@ -161,7 +161,7 @@ async function request(url, options = { headers: {} }) {
161
161
  response.statusMessage = res.statusMessage;
162
162
  response.headers = res.headers;
163
163
  response.body = data;
164
- if (response.body && response.headers["content-type"] && response.headers["content-type"].includes("application/json"))
164
+ if (response.body && response.headers["content-type"] && response.headers["content-type"].includes("application/json") && typeof response.body === "string" && (response.body.startsWith("{") || response.body.startsWith("[")))
165
165
  try {
166
166
  response.body = (options.parse || JSON.parse)(response.body);
167
167
  logger.debug("response.parse JSON");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/request",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,10 +21,10 @@
21
21
  "dist"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@faasjs/logger": "1.3.2"
24
+ "@faasjs/logger": "1.4.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@faasjs/logger": "1.3.2"
27
+ "@faasjs/logger": "1.4.0"
28
28
  },
29
29
  "engines": {
30
30
  "npm": ">=9.0.0",