feat: parse body from url params
This commit is contained in:
committed by
Andrew Bastin
parent
b10933898f
commit
f428a21279
@@ -136,7 +136,10 @@ import {
|
|||||||
} from "~/helpers/utils/composables"
|
} from "~/helpers/utils/composables"
|
||||||
import { loadRequestFromSync, startRequestSync } from "~/helpers/fb/request"
|
import { loadRequestFromSync, startRequestSync } from "~/helpers/fb/request"
|
||||||
import { onLoggedIn } from "~/helpers/fb/auth"
|
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 { oauthRedirect } from "~/helpers/oauth"
|
||||||
import { HoppRESTAuthOAuth2 } from "~/helpers/types/HoppRESTAuth"
|
import { HoppRESTAuthOAuth2 } from "~/helpers/types/HoppRESTAuth"
|
||||||
import useWindowSize from "~/helpers/utils/useWindowSize"
|
import useWindowSize from "~/helpers/utils/useWindowSize"
|
||||||
@@ -161,6 +164,17 @@ function bindRequestToURLParams() {
|
|||||||
return filtered.length > 0 ? JSON.stringify(filtered) : null
|
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
|
// Combine them together to a cleaner value
|
||||||
const urlParams = computed(() => ({
|
const urlParams = computed(() => ({
|
||||||
v: request.value.v,
|
v: request.value.v,
|
||||||
@@ -168,6 +182,7 @@ function bindRequestToURLParams() {
|
|||||||
endpoint: request.value.endpoint,
|
endpoint: request.value.endpoint,
|
||||||
headers: headers.value,
|
headers: headers.value,
|
||||||
params: params.value,
|
params: params.value,
|
||||||
|
body: JSON.stringify({ contentType, body }),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Watch and update accordingly
|
// Watch and update accordingly
|
||||||
|
|||||||
Reference in New Issue
Block a user