Skip to content

Commit

Permalink
chore: add api url
Browse files Browse the repository at this point in the history
  • Loading branch information
codingknite committed Aug 16, 2024
1 parent a2dc835 commit 07d4844
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions lib/hooks/useArweaveId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,23 @@ interface ArweaveIdProps {
arweaveId: string;
}

// interface Props {
// block: number | undefined | null;
// }

export function useArweaveId() {
// const fetchArweaveId = async() => {
// const response = await fetch(config.googleCloud.nextAPI, {
// method: 'POST',
// body: JSON.stringify({
// blockNumber: block,
// }),
// headers: {
// 'Content-Type': 'application/json',
// },
// });

// if (response.ok && response.status === 200) {
// const data = (await response.json()) as ArweaveIdProps;
// return data.arweaveId;
// }
// };
interface BlockProps {
block: number | undefined | null;
}

export function useArweaveId({ block }: BlockProps) {
const fetchArweaveId = async() => {
const response = await fetch(
'https://arweaveid-api.vercel.app/api/arweave-id',
{
method: 'POST',
body: JSON.stringify({
blockNumber: block,
}),
headers: {
'Content-Type': 'application/json',
},
},
);

if (response.ok && response.status === 200) {
Expand All @@ -40,6 +32,7 @@ export function useArweaveId() {
const { data, error, isLoading } = useQuery({
queryKey: [ 'getArweaveId' ],
queryFn: () => fetchArweaveId(),
enabled: !block,
});

return { data, error, isLoading };
Expand Down

0 comments on commit 07d4844

Please sign in to comment.