diff --git a/idea/frontend/src/features/balance/api.ts b/idea/frontend/src/features/balance/api.ts index d69199510..ab099ce67 100644 --- a/idea/frontend/src/features/balance/api.ts +++ b/idea/frontend/src/features/balance/api.ts @@ -1,4 +1,4 @@ -import { CONTENT_TYPE_HEADERS, GENESIS } from '@/shared/config'; +import { GENESIS } from '@/shared/config'; import { fetchWithGuard } from '@/shared/helpers'; import { FAUCET_API_URL } from './consts'; @@ -10,7 +10,6 @@ type GetTestBalanceParameters = { const getTestBalance = ({ token, address }: GetTestBalanceParameters) => fetchWithGuard(`${FAUCET_API_URL}/balance`, { method: 'POST', - headers: CONTENT_TYPE_HEADERS, body: JSON.stringify({ token, payload: { address, genesis: GENESIS.TESTNET } }), }); export { getTestBalance }; diff --git a/idea/frontend/src/features/metadata/api/requests.ts b/idea/frontend/src/features/metadata/api/requests.ts index 7e1b394f5..65bc25e73 100644 --- a/idea/frontend/src/features/metadata/api/requests.ts +++ b/idea/frontend/src/features/metadata/api/requests.ts @@ -1,6 +1,6 @@ import { HexString } from '@polkadot/util/types'; -import { CONTENT_TYPE_HEADERS, METADATA_STORAGE_API_URL } from '@/shared/config'; +import { METADATA_STORAGE_API_URL } from '@/shared/config'; import { fetchWithGuard } from '@/shared/helpers'; import { GetMetaResponse } from './types'; @@ -14,7 +14,6 @@ const fetchMetadata = (hash: HexString) => { const addMetadata = (hash: HexString, hex: HexString) => fetchWithGuard(`${METADATA_STORAGE_API_URL}/meta`, { method: 'POST', - headers: CONTENT_TYPE_HEADERS, body: JSON.stringify({ hash, hex }), }); diff --git a/idea/frontend/src/features/sails/api/requests.ts b/idea/frontend/src/features/sails/api/requests.ts index 2fbb25f22..2f2fcdfcb 100644 --- a/idea/frontend/src/features/sails/api/requests.ts +++ b/idea/frontend/src/features/sails/api/requests.ts @@ -1,7 +1,7 @@ import { HexString } from '@gear-js/api'; import { PaginationResponse } from '@/api'; -import { CONTENT_TYPE_HEADERS, METADATA_STORAGE_API_URL } from '@/shared/config'; +import { METADATA_STORAGE_API_URL } from '@/shared/config'; import { fetchWithGuard } from '@/shared/helpers'; import { INDEXER_RPC_SERVICE } from '@/shared/services/rpcService'; @@ -18,7 +18,6 @@ const getIdl = (codeId: HexString) => { const addIdl = (codeId: HexString, data: string) => fetchWithGuard(`${METADATA_STORAGE_API_URL}/sails`, { method: 'POST', - headers: CONTENT_TYPE_HEADERS, body: JSON.stringify({ codeId, data }), }); diff --git a/idea/frontend/src/shared/config/consts.ts b/idea/frontend/src/shared/config/consts.ts index c82460340..60a1a6632 100644 --- a/idea/frontend/src/shared/config/consts.ts +++ b/idea/frontend/src/shared/config/consts.ts @@ -36,8 +36,6 @@ const PROGRAM_ERRORS = { PROGRAM_INIT_FAILED: 'Program initialization failed', }; -const CONTENT_TYPE_HEADERS = { 'Content-Type': 'application/json;charset=utf-8' }; - enum LocalStorage { Node = 'node', Nodes = 'nodes', @@ -112,7 +110,6 @@ export { PROGRAM_ERRORS, GENESIS, ACCOUNT_ADDRESS_SCHEMA, - CONTENT_TYPE_HEADERS, LocalStorage, GasMethod, TransactionName, diff --git a/idea/frontend/src/shared/helpers/index.ts b/idea/frontend/src/shared/helpers/index.ts index 34116fdd8..928eb8b7b 100644 --- a/idea/frontend/src/shared/helpers/index.ts +++ b/idea/frontend/src/shared/helpers/index.ts @@ -126,6 +126,9 @@ const isHex = (value: unknown): value is HexString => { }; const fetchWithGuard = async (...args: Parameters) => { + if (args?.[1]?.method === 'POST') { + args[1].headers = { 'Content-Type': 'application/json;charset=utf-8', ...args[1]?.headers }; + } const response = await fetch(...args); if (!response.ok) throw new Error(response.statusText);