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>
This commit is contained in:
parent
20410aeb03
commit
fef1e35c54
@ -29,11 +29,15 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
|
|||||||
baseURL,
|
baseURL,
|
||||||
transformResponse: (data: any, header: AxiosResponseHeaders) => {
|
transformResponse: (data: any, header: AxiosResponseHeaders) => {
|
||||||
// storeAsString指示将BigInt存储为字符串,设为false则会存储为内置的BigInt类型
|
// storeAsString指示将BigInt存储为字符串,设为false则会存储为内置的BigInt类型
|
||||||
return header.getContentType()?.toString().includes('application/json')
|
if (
|
||||||
? cloneDeep(
|
header.getContentType()?.toString().includes('application/json') &&
|
||||||
JSONBigInt({ storeAsString: true, strict: true }).parse(data),
|
typeof data === 'string'
|
||||||
)
|
) {
|
||||||
: data;
|
return cloneDeep(
|
||||||
|
JSONBigInt({ storeAsString: true, strict: true }).parse(data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user