azure-iot-http-base
Advanced tools
Comparing version
@@ -123,5 +123,22 @@ // Copyright (c) Microsoft. All rights reserved. | ||
else { | ||
/*Codes_SRS_NODE_IOTHUB_REST_API_CLIENT_16_009: [If the HTTP request is successful the `executeApiCall` method shall parse the JSON response received and call the `done` callback with a `null` first argument, the parsed result as a second argument and the HTTP response object itself as a third argument.]*/ | ||
var result = responseBody ? JSON.parse(responseBody) : ''; | ||
done(null, result, response); | ||
/*Codes_SRS_NODE_IOTHUB_REST_API_CLIENT_16_009: [If the HTTP request is successful and the content-type header contains `application/json` the `executeApiCall` method shall parse the JSON response received and call the `done` callback with a `null` first argument, the parsed result as a second argument and the HTTP response object itself as a third argument.]*/ | ||
var result = ''; | ||
var parseError = null; | ||
/*Codes_SRS_NODE_IOTHUB_REST_API_CLIENT_16_037: [If parsing the body of the HTTP response as JSON fails, the `done` callback shall be called with the SyntaxError thrown as a first argument, an `undefined` second argument, and the HTTP response object itself as a third argument.]*/ | ||
var expectJson = response.headers && response.headers['content-type'] && response.headers['content-type'].indexOf('application/json') >= 0; | ||
if (responseBody && expectJson) { | ||
try { | ||
result = JSON.parse(responseBody); | ||
} | ||
catch (ex) { | ||
if (ex instanceof SyntaxError) { | ||
parseError = ex; | ||
result = undefined; | ||
} | ||
else { | ||
throw ex; | ||
} | ||
} | ||
} | ||
done(parseError, result, response); | ||
} | ||
@@ -128,0 +145,0 @@ }; |
{ | ||
"name": "azure-iot-http-base", | ||
"version": "1.8.2", | ||
"version": "1.9.0-preview.0", | ||
"description": "HTTP operations used by Azure IoT device and service SDKs", | ||
@@ -10,3 +10,3 @@ "author": "Microsoft Corporation", | ||
"dependencies": { | ||
"azure-iot-common": "1.8.2", | ||
"azure-iot-common": "1.9.0-preview.0", | ||
"debug": "^3.1.0", | ||
@@ -13,0 +13,0 @@ "uuid": "^3.2.1" |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
42837
2.47%714
2.44%1
Infinity%+ Added
- Removed