Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: parsing

Manda Putra5dcfa66c5da2
diff --git a/packages/hoppscotch-app/helpers/RESTExtURLParams.ts b/packages/hoppscotch-app/helpers/RESTExtURLParams.ts
index 1746bf197..9b75a6690 100644
--- a/packages/hoppscotch-app/helpers/RESTExtURLParams.ts
+++ b/packages/hoppscotch-app/helpers/RESTExtURLParams.ts
@@ -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
}
diff --git a/packages/hoppscotch-app/pages/index.vue b/packages/hoppscotch-app/pages/index.vue
index 33453d804..fa93b3d2b 100644
--- a/packages/hoppscotch-app/pages/index.vue
+++ b/packages/hoppscotch-app/pages/index.vue
@@ -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