Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
if (err) return callback(err);
// Create Result
let result = null;
request = pollingResult.request;
response = pollingResult.response;
let responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;
// Deserialize Response
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined && options.deserializationMapperForTerminalResponse) {
result = msRest.deserialize(options.deserializationMapperForTerminalResponse, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error "${JSON.stringify(error, null, 2)}" occurred in deserializing the responseBody - "${responseBody}".`);
deserializationError.request = msRest.stripRequest(request);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
return callback(null, result, request, response);
});
});