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:
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user