fix: parsing

This commit is contained in:
Manda Putra
2021-10-03 08:49:33 +07:00
committed by Andrew Bastin
parent f428a21279
commit 5dcfa66c5d
2 changed files with 8 additions and 5 deletions

View File

@@ -109,5 +109,9 @@ function parseV1ExtURL(urlParams: Record<string, any>): HoppRESTRequest {
resolvedReq.endpoint = urlParams.endpoint
}
if (urlParams.body && typeof urlParams.body === "string") {
resolvedReq.body = JSON.parse(urlParams.body)
}
return resolvedReq
}

View File

@@ -164,15 +164,14 @@ function bindRequestToURLParams() {
return filtered.length > 0 ? JSON.stringify(filtered) : null
})
const contentType = request.value.body.contentType
const body = computed(() => {
const contentType = request.value.body.contentType
if (contentType === "multipart/form-data") {
const body = request.value.body.body as FormDataKeyValue[]
const filtered = body.filter((x) => x.key !== "")
return filtered.length > 0 ? JSON.stringify(filtered) : null
return JSON.stringify({ body: filtered, contentType })
}
return JSON.stringify(request.value.body)
return JSON.stringify({ body: request.value.body.body, contentType })
})
// Combine them together to a cleaner value
@@ -182,7 +181,7 @@ function bindRequestToURLParams() {
endpoint: request.value.endpoint,
headers: headers.value,
params: params.value,
body: JSON.stringify({ contentType, body }),
body: body.value,
}))
// Watch and update accordingly