Files
js/@3rdweb-sdk/react/hooks/useWalletNFTs.ts
T

23 lines
670 B
TypeScript

import { useQueryWithNetwork } from "./query/useQueryWithNetwork";
import { useActiveChainId } from "./useActiveChainId";
import { useAddress } from "@thirdweb-dev/react";
import { WalletNFTApiReturn } from "pages/api/wallet/nfts/[chainId]";
export function useWalletNFTs() {
const activeChainId = useActiveChainId();
const address = useAddress();
return useQueryWithNetwork(
["walletNfts", address],
async () => {
const response = await fetch(
`/api/wallet/nfts/${activeChainId}?owner=${address}`,
);
return (await response.json()) as WalletNFTApiReturn;
},
{
enabled: !!address && !!activeChainId,
},
);
}