mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 12:20:34 +00:00
fix: form-data not display in http node log (#2868)
* fix: fix form-data not display in http node log * fix
This commit is contained in:
@@ -184,6 +184,21 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
}
|
||||
})();
|
||||
|
||||
const formattedRequestBody: Record<string, any> = (() => {
|
||||
if (requestBody instanceof FormData || requestBody instanceof URLSearchParams) {
|
||||
return Object.fromEntries(requestBody);
|
||||
} else if (typeof requestBody === 'string') {
|
||||
try {
|
||||
return JSON.parse(requestBody);
|
||||
} catch {
|
||||
return { content: requestBody };
|
||||
}
|
||||
} else if (typeof requestBody === 'object' && requestBody !== null) {
|
||||
return requestBody;
|
||||
}
|
||||
return {};
|
||||
})();
|
||||
|
||||
try {
|
||||
const { formatResponse, rawResponse } = await (async () => {
|
||||
const systemPluginCb = await getSystemPluginCb();
|
||||
@@ -225,7 +240,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
totalPoints: 0,
|
||||
params: Object.keys(params).length > 0 ? params : undefined,
|
||||
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
|
||||
body: Object.keys(formattedRequestBody).length > 0 ? formattedRequestBody : undefined,
|
||||
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
||||
httpResult: rawResponse
|
||||
},
|
||||
@@ -241,7 +256,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
[NodeOutputKeyEnum.error]: formatHttpError(error),
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
params: Object.keys(params).length > 0 ? params : undefined,
|
||||
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
|
||||
body: Object.keys(formattedRequestBody).length > 0 ? formattedRequestBody : undefined,
|
||||
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
||||
httpResult: { error: formatHttpError(error) }
|
||||
},
|
||||
|
Reference in New Issue
Block a user