Show clear error message on API rate limit (429)

Free plan allows 10 requests/min; show a Dutch user-friendly message
instead of a generic API error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 06:41:15 +01:00
parent c0ca5b9072
commit 0209aa806e

View File

@@ -5,6 +5,7 @@ const DEV_KEY = import.meta.env.VITE_FOOTBALL_API_KEY
export function apiFetch(path) {
const headers = DEV_KEY ? { 'X-Auth-Token': DEV_KEY } : {}
return fetch(`/api${path}`, { headers }).then((res) => {
if (res.status === 429) throw new Error('Limiet bereikt: het gratis abonnement staat maximaal 10 verzoeken per minuut toe. Wacht even en probeer het opnieuw.')
if (!res.ok) throw new Error(`API error: ${res.status} ${res.statusText}`)
return res.json()
})