From fef1e35c54c7805fcc3813a1edf64e12ed6ff8f0 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 11:49:38 +0800 Subject: [PATCH] fix: prevent JSONBigInt parsing error on non-string data (#6891) * Initial plan * Fix json-bigint serialization error when data is not a string Co-authored-by: likui628 <90845831+likui628@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: likui628 <90845831+likui628@users.noreply.github.com> --- playground/src/api/request.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/playground/src/api/request.ts b/playground/src/api/request.ts index e741552d..a8855361 100644 --- a/playground/src/api/request.ts +++ b/playground/src/api/request.ts @@ -29,11 +29,15 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) { baseURL, transformResponse: (data: any, header: AxiosResponseHeaders) => { // storeAsString指示将BigInt存储为字符串,设为false则会存储为内置的BigInt类型 - return header.getContentType()?.toString().includes('application/json') - ? cloneDeep( - JSONBigInt({ storeAsString: true, strict: true }).parse(data), - ) - : data; + if ( + header.getContentType()?.toString().includes('application/json') && + typeof data === 'string' + ) { + return cloneDeep( + JSONBigInt({ storeAsString: true, strict: true }).parse(data), + ); + } + return data; }, });