feat: parse body from url params

This commit is contained in:
Manda Putra
2021-10-03 06:52:56 +07:00
committed by Andrew Bastin
parent b10933898f
commit f428a21279

View File

@@ -136,7 +136,10 @@ import {
} from "~/helpers/utils/composables"
import { loadRequestFromSync, startRequestSync } from "~/helpers/fb/request"
import { onLoggedIn } from "~/helpers/fb/auth"
import { HoppRESTRequest } from "~/helpers/types/HoppRESTRequest"
import {
FormDataKeyValue,
HoppRESTRequest,
} from "~/helpers/types/HoppRESTRequest"
import { oauthRedirect } from "~/helpers/oauth"
import { HoppRESTAuthOAuth2 } from "~/helpers/types/HoppRESTAuth"
import useWindowSize from "~/helpers/utils/useWindowSize"
@@ -161,6 +164,17 @@ function bindRequestToURLParams() {
return filtered.length > 0 ? JSON.stringify(filtered) : null
})
const contentType = request.value.body.contentType
const body = computed(() => {
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(request.value.body)
})
// Combine them together to a cleaner value
const urlParams = computed(() => ({
v: request.value.v,
@@ -168,6 +182,7 @@ function bindRequestToURLParams() {
endpoint: request.value.endpoint,
headers: headers.value,
params: params.value,
body: JSON.stringify({ contentType, body }),
}))
// Watch and update accordingly