feat: update API endpoint handling in frontend components for activities, leaderboard, teams, users, and workouts

This commit is contained in:
2026-06-20 02:30:34 +00:00
parent e046a15409
commit dec27a442e
5 changed files with 25 additions and 10 deletions
@@ -4,9 +4,12 @@ function Teams() {
const [teams, setTeams] = useState([])
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
const endpoint = import.meta.env.VITE_CODESPACE_NAME
? `https://${import.meta.env.VITE_CODESPACE_NAME}-8000.app.github.dev/api/teams/`
: '/api/teams/'
useEffect(() => {
fetch('/api/teams/')
fetch(endpoint)
.then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return res.json()
@@ -19,7 +22,7 @@ function Teams() {
setError(err.message)
setLoading(false)
})
}, [])
}, [endpoint])
if (loading) return <p>Loading teams</p>
if (error) return <p className="text-danger">Error: {error}</p>