Stopping get requests from having bodies (Node fetch doesn't allow this) and allow text body type.
This commit is contained in:
parent
e7b9b02b9e
commit
17f083e586
|
@ -48,7 +48,7 @@
|
|||
let breakQs = {},
|
||||
bindings = {}
|
||||
let url = ""
|
||||
let saveId
|
||||
let saveId, isGet
|
||||
let response, schema, enabledHeaders
|
||||
let datasourceType, integrationInfo, queryConfig, responseSuccess
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
|||
$: queryConfig = integrationInfo?.query
|
||||
$: url = buildUrl(url, breakQs)
|
||||
$: checkQueryName(url)
|
||||
$: isGet = query?.queryVerb === "read"
|
||||
$: responseSuccess =
|
||||
response?.info?.code >= 200 && response?.info?.code <= 206
|
||||
|
||||
|
@ -226,7 +227,7 @@
|
|||
<Tab title="Body">
|
||||
<RadioGroup
|
||||
bind:value={query.fields.bodyType}
|
||||
options={bodyTypes}
|
||||
options={isGet ? [bodyTypes[0]] : bodyTypes}
|
||||
direction="horizontal"
|
||||
getOptionLabel={option => option.name}
|
||||
getOptionValue={option => option.value}
|
||||
|
|
|
@ -162,18 +162,25 @@ module RestModule {
|
|||
}
|
||||
}
|
||||
|
||||
let json
|
||||
if (bodyType === BodyTypes.JSON && requestBody) {
|
||||
const input: any = { method, headers: this.headers }
|
||||
if (requestBody) {
|
||||
switch (bodyType) {
|
||||
case BodyTypes.TEXT:
|
||||
const text = typeof requestBody !== "string" ? JSON.stringify(requestBody) : requestBody
|
||||
input.body = text
|
||||
break
|
||||
default: case BodyTypes.JSON:
|
||||
try {
|
||||
json = JSON.parse(requestBody)
|
||||
// confirm its json
|
||||
const json = JSON.parse(requestBody)
|
||||
if (json && typeof json === "object" && Object.keys(json).length > 0) {
|
||||
input.body = requestBody
|
||||
}
|
||||
} catch (err) {
|
||||
throw "Invalid JSON for request body"
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
const input: any = { method, headers: this.headers }
|
||||
if (json && typeof json === "object" && Object.keys(json).length > 0) {
|
||||
input.body = JSON.stringify(json)
|
||||
}
|
||||
|
||||
this.startTimeMs = performance.now()
|
||||
|
|
Loading…
Reference in New Issue