@unboundcx/sdk 2.7.5 → 2.7.6

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/base.js +6 -4
  2. package/package.json +1 -1
package/base.js CHANGED
@@ -324,12 +324,14 @@ export class BaseSDK {
324
324
  responseHeaders?.get?.('x-request-id') ||
325
325
  responseHeaders?.['x-request-id'] || '';
326
326
 
327
+ const contentType = responseHeaders?.get?.('content-type') || response.headers['content-type'];
328
+
327
329
  if (!response.ok) {
328
330
  let errorBody;
329
331
  if (response?.body) {
330
332
  errorBody = response.body;
331
333
  } else if (response?.headers?.['content-type']) {
332
- const contentType = response.headers['content-type'];
334
+
333
335
  try {
334
336
  if (typeof response?.json === 'function' || typeof response?.text === 'function') {
335
337
  if (contentType.includes('application/json')) {
@@ -372,10 +374,10 @@ export class BaseSDK {
372
374
  }
373
375
 
374
376
  let responseBody;
375
- if (response?.body) {
377
+ if (response?.body && !contentType) {
376
378
  responseBody = response.body;
377
- } else if (response?.headers?.['content-type']) {
378
- const contentType = response.headers['content-type'];
379
+ } else if (contentType) {
380
+
379
381
  try {
380
382
  if (transport === 'https') {
381
383
  if (contentType.includes('application/json')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.7.5",
3
+ "version": "2.7.6",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",