@nrfcloud/api-client-javascript
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -31,2 +31,5 @@ import { TenantsList } from "./types/TenantsList"; | ||
* (The tenants for the authenticated user) | ||
* - for status 201 | ||
* a TenantsList as application/json | ||
* (A list with the the tenant which was just created.) | ||
* - for status 400 | ||
@@ -33,0 +36,0 @@ * a HttpProblem as application/json |
@@ -39,9 +39,16 @@ "use strict"; | ||
throw new TypeError(`The content-type "${contentType}" of the response is not JSON!`); | ||
const json = yield res.json(); | ||
if (res.status >= 400) | ||
if (json.$context === models_1.HttpProblem.$context.toString()) | ||
throw models_1.HttpProblem.fromJSON(json); | ||
else | ||
throw new models_1.ApplicationError(JSON.stringify(json)); | ||
return json; | ||
const status = res.status; | ||
const contentLength = +(res.headers.get("content-length") || 0); | ||
if (status >= 400) { | ||
if (contentLength) { | ||
const json = yield res.json(); | ||
if (json.$context === models_1.HttpProblem.$context.toString()) | ||
throw models_1.HttpProblem.fromJSON(json); | ||
else | ||
throw new models_1.ApplicationError(JSON.stringify(json)); | ||
} | ||
throw new models_1.ApplicationError(`Response status code was ${status}, but not response was returned.`); | ||
} | ||
if (contentLength) | ||
return yield res.json(); | ||
}); | ||
@@ -59,2 +66,5 @@ } | ||
* (The tenants for the authenticated user) | ||
* - for status 201 | ||
* a TenantsList as application/json | ||
* (A list with the the tenant which was just created.) | ||
* - for status 400 | ||
@@ -61,0 +71,0 @@ * a HttpProblem as application/json |
{ | ||
"name": "@nrfcloud/api-client-javascript", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "JavaScript API client for the nRFCloud.com REST API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22577
559