diff --git a/.changeset/bright-melons-think.md b/.changeset/bright-melons-think.md new file mode 100644 index 00000000..107f4433 --- /dev/null +++ b/.changeset/bright-melons-think.md @@ -0,0 +1,5 @@ +--- +'@bnb-chain/greenfield-js-sdk': patch +--- + +fix: Using Cross Fetch replace native fetch (occurs on Nodejs 18-) diff --git a/packages/js-sdk/src/clients/spclient/spClient.ts b/packages/js-sdk/src/clients/spclient/spClient.ts index 9f748199..e6b3ecfd 100644 --- a/packages/js-sdk/src/clients/spclient/spClient.ts +++ b/packages/js-sdk/src/clients/spclient/spClient.ts @@ -8,6 +8,7 @@ import { import { parseError } from '@/clients/spclient/spApis/parseError'; import { SP_NOT_AVAILABLE_ERROR_CODE, SP_NOT_AVAILABLE_ERROR_MSG } from '@/constants/http'; import { AuthType, ReqMeta } from '@/types/auth'; +import { fetchWithTimeout } from '@/utils/http'; import { injectable } from 'tsyringe'; import { getGetObjectMetaInfo } from './spApis/getObject'; import { getPutObjectMetaInfo } from './spApis/putObject'; @@ -55,7 +56,7 @@ export class SpClient implements ISpClient { try { const controller = new AbortController(); const _id = setTimeout(() => controller.abort(), timeout); - const response = await fetch(url, { + const response = await fetchWithTimeout(url, { ...options, signal: controller.signal, });