set response.parsedBody as-is if the reponse body sent by the service is a string instead of a JSON object.

This commit is contained in:
Amar Zavery 2019-07-30 19:08:57 -07:00
Родитель 343edc9ccf
Коммит ac165424ad
4 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -1,4 +1,7 @@
# Changelog
## 2.0.1 - 2019-07-30
- In `getOperationResponse()` if the `resource` is of type `string` and we get an error while performing `JSON.parse()` then instead of letting the error be thrown we set the `resource` as-is as the `response.parsedBody`
## 2.0.0 - 2019-07-15
- Bumping the version to `2.0.0` since the underlying dependency `@azure/ms-rest-js` has moved to `2.x.x` range.
- `@azure/ms-rest-js@2.x.x` is using `node-fetch` instead of `axios` as the http client for node.js scenario.

Просмотреть файл

@ -86,7 +86,13 @@ export abstract class LROPollStrategy {
result.parsedBody = response.parsedBody;
} else if (typeof resource.valueOf() === "string") {
result.bodyAsText = resource;
result.parsedBody = JSON.parse(resource);
try {
result.parsedBody = JSON.parse(resource);
} catch (err) {
// There was an error parsing the JSON. Hence we set the resource as-is. Most likely, the
// resource is a string that was already parsed.
result.parsedBody = resource;
}
} else {
result.bodyAsText = JSON.stringify(resource);
result.parsedBody = resource;

Просмотреть файл

@ -27,4 +27,4 @@ export const DEFAULT_LANGUAGE = "en-us";
* @const
* @type {string}
*/
export const msRestAzureVersion = "2.0.0";
export const msRestAzureVersion = "2.0.1";

Просмотреть файл

@ -5,7 +5,7 @@
"email": "azsdkteam@microsoft.com",
"url": "https://github.com/Azure/ms-rest-azure-js"
},
"version": "2.0.0",
"version": "2.0.1",
"description": "Isomorphic Azure client runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest",
"tags": [
"isomorphic",
@ -41,7 +41,7 @@
],
"license": "MIT",
"dependencies": {
"@azure/ms-rest-js": "^2.0.3",
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
},
"devDependencies": {
@ -111,4 +111,4 @@
"check:everything": "ts-node ./.scripts/checkEverything.ts"
},
"sideEffects": false
}
}