Skip to content

Commit

Permalink
fix: parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mandaputtra authored and AndrewBastin committed Oct 3, 2021
1 parent f428a21 commit 5dcfa66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/hoppscotch-app/helpers/RESTExtURLParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 4 additions & 5 deletions packages/hoppscotch-app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5dcfa66

Please sign in to comment.