From 8d8bd877aba89f5e4937459e106aa165f4b36c9f Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-lf Date: Mon, 23 Oct 2023 12:54:12 -0700 Subject: [PATCH] SNOW-502598: Parse data back into JSON --- lib/connection/connection.js | 2 +- lib/http/base.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/connection/connection.js b/lib/connection/connection.js index 642349cb1..ef0a57afe 100644 --- a/lib/connection/connection.js +++ b/lib/connection/connection.js @@ -448,7 +448,7 @@ function Connection(context) // Get the response containing the query status const response = await services.sf.requestAsync(options); - return JSON.parse(response['data']); + return response['body']; } /** diff --git a/lib/http/base.js b/lib/http/base.js index 2d92f9650..f3a2968d1 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -85,7 +85,14 @@ HttpClient.prototype.requestAsync = async function (options) { const requestOptions = prepareRequestOptions.call(this, options); - return axios.request(requestOptions); + let response = await axios.request(requestOptions); + + if (Util.isString(response['data']) && + response['headers']['content-type'] === 'application/json') { + response['data'] = JSON.parse(response['data']); + } + + return normalizeResponse(response); }; /**