Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e0295f

Browse files
committed
fix body issue
1 parent850ccda commit1e0295f

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

‎client/packages/lowcoder/src/comps/queries/queryComp.tsx

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,22 +761,52 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
761761

762762
// If this is a REST API created from cURL, pre-populate the HTTP query fields
763763
if(compType==="restApi"&&curlData){
764-
constheadersArr=curlData.header
765-
?Object.entries(curlData.header).map(([key,value])=>({ key, value}))
764+
// Normalize possible field names returned by different curl parsers
765+
constrawHeaders:Record<string,any>|undefined=
766+
curlData.header||curlData.headers;
767+
constrawParams:Record<string,any>|undefined=
768+
curlData.params||curlData.parameters||curlData.query;
769+
770+
// Convert headers & params objects to the key/value array expected by the UI controls
771+
constheadersArr=rawHeaders
772+
?Object.entries(rawHeaders).map(([key,value])=>({ key, value}))
766773
:[{key:"",value:""}];
767-
constparamsArr=curlData.params
768-
?Object.entries(curlData.params).map(([key,value])=>({ key, value}))
774+
775+
constparamsArr=rawParams
776+
?Object.entries(rawParams).map(([key,value])=>({ key, value}))
769777
:[{key:"",value:""}];
770778

779+
// Detect request body – different parsers may expose it under various keys
780+
constbodyContent:any=
781+
curlData.body??curlData.data??curlData.postData??undefined;
782+
783+
// Determine body type – prefer the Content-Type header if present
784+
letbodyType:string="none";
785+
if(bodyContent!==undefined&&bodyContent!==""){
786+
constcontentTypeHeader=
787+
(rawHeaders&&(rawHeaders["Content-Type"]||rawHeaders["content-type"]))||
788+
"";
789+
if(contentTypeHeader){
790+
bodyType=contentTypeHeader;
791+
}elseif(typeofbodyContent==="object"){
792+
bodyType="application/json";
793+
}else{
794+
bodyType="text/plain";
795+
}
796+
}
797+
771798
payload={
772799
...payload,
773800
comp:{
774801
httpMethod:curlData.method||"GET",
775-
path:curlData.url||"",
802+
path:curlData.url||curlData.path||"",
776803
headers:headersArr,
777804
params:paramsArr,
778-
bodyType:curlData.body ?"application/json" :"none",
779-
body:curlData.body ?JSON.stringify(curlData.body,null,2) :"",
805+
bodyType:bodyType,
806+
body:
807+
typeofbodyContent==="object"
808+
?JSON.stringify(bodyContent,null,2)
809+
:bodyContent||"",
780810
bodyFormData:[{key:"",value:"",type:"text"}],
781811
},
782812
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp