import React from 'react' import Link from 'next/link' import { useQuery } from '@tanstack/react-query' import { usePathname } from 'next/navigation' async function fetchProject(id: string): Promise<{ forks_count: number stargazers_count: number watchers_count: number }> { console.info('Fetching project:', id) const response = await fetch(`https://api.github.com/repos/${id}`) await new Promise((r) => setTimeout(r, 1000)) return await response.json() } export default function Repo() { const id = usePathname() const { status, data, error, isFetching } = useQuery({ queryKey: ['team', id], queryFn: () => fetchProject(id), }) return (

{id}

{status === 'pending' ? ( 'Loading...' ) : status === 'error' ? ( Error: {error.message} ) : ( <>

forks: {data.forks_count}

stars: {data.stargazers_count}

watchers: {data.watchers_count}

{isFetching ? 'Background Updating...' : ' '}
)}

Back
) }