diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/index.svelte
index 1dab4a9cef..d469053c89 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/index.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/index.svelte
@@ -32,12 +32,11 @@
} from "constants/backend"
import JSONPreview from "components/integration/JSONPreview.svelte"
- let query
+ let query, datasource
let breakQs = {}
let url = ""
- // test - { info: { code: 500, time: "455ms", size: "2.09KB" }}
- let response
- let schema
+ let response, schema
+ let datasourceType, integrationInfo, queryConfig, responseSuccess
$: datasource = $datasources.list.find(ds => ds._id === query?.datasourceId)
$: datasourceType = datasource?.source
@@ -242,12 +241,11 @@
bind:object={response.schema}
name="header"
headings
- activity
options={SchemaTypeOptions}
/>
-
+
{#if response}
diff --git a/packages/server/src/api/controllers/query.js b/packages/server/src/api/controllers/query.js
index b24513ba79..f5a0d28960 100644
--- a/packages/server/src/api/controllers/query.js
+++ b/packages/server/src/api/controllers/query.js
@@ -109,7 +109,7 @@ exports.preview = async function (ctx) {
const enrichedQuery = await enrichQueryFields(fields, parameters)
try {
- const { rows, keys, info } = await Runner.run({
+ const { rows, keys, info, raw } = await Runner.run({
datasource,
queryVerb,
query: enrichedQuery,
@@ -120,6 +120,7 @@ exports.preview = async function (ctx) {
rows,
schemaFields: [...new Set(keys)],
info,
+ raw,
}
} catch (err) {
ctx.throw(400, err)
diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts
index 5228dc83f5..57bd11ef9a 100644
--- a/packages/server/src/integrations/rest.ts
+++ b/packages/server/src/integrations/rest.ts
@@ -118,12 +118,14 @@ module RestModule {
}
async parseResponse(response: any) {
- let data
+ let data, raw
const contentType = response.headers.get("content-type")
if (contentType && contentType.indexOf("application/json") !== -1) {
data = await response.json()
+ raw = JSON.stringify(data)
} else {
data = await response.text()
+ raw = data
}
const size = formatBytes(response.headers.get("content-length") || 0)
const time = `${Math.round(performance.now() - this.startTimeMs)}ms`
@@ -134,6 +136,7 @@ module RestModule {
size,
time,
},
+ raw,
}
}
diff --git a/packages/server/src/threads/query.js b/packages/server/src/threads/query.js
index 9995116fdc..d94c4e6c2c 100644
--- a/packages/server/src/threads/query.js
+++ b/packages/server/src/threads/query.js
@@ -33,10 +33,12 @@ async function runAndTransform(datasource, queryVerb, query, transformer) {
let output = formatResponse(await integration[queryVerb](query))
let rows = output,
- info = undefined
+ info = undefined,
+ raw = undefined
if (hasExtraData(output)) {
rows = output.data
info = output.info
+ raw = output.raw
}
// transform as required
@@ -62,7 +64,7 @@ async function runAndTransform(datasource, queryVerb, query, transformer) {
integration.end()
}
- return { rows, keys, info }
+ return { rows, keys, info, raw }
}
module.exports = (input, callback) => {