@reservoir0x/relay-kit-hooks
Version:
Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.
24 lines • 939 B
JavaScript
import { axiosPostFetcher } from '../fetcher.js';
import { useMemo } from 'react';
import { MAINNET_RELAY_API } from '@reservoir0x/relay-sdk';
import { useQuery } from '@tanstack/react-query';
export const queryTokenList = function (baseApiUrl = MAINNET_RELAY_API, options, headers) {
const url = new URL(`${baseApiUrl}/currencies/v2`);
return axiosPostFetcher(url.href, options, headers);
};
export default function (baseApiUrl, options, queryOptions) {
const response = useQuery({
queryKey: ['useTokenList', options],
queryFn: () => queryTokenList(baseApiUrl, options),
enabled: options ? true : false,
retry: false,
...queryOptions
});
return useMemo(() => {
return {
...response,
data: response.error ? undefined : response.data
};
}, [response.data, response.error, response.isLoading]);
}
//# sourceMappingURL=useTokenList.js.map