surface retryable tender feed outages

This commit is contained in:
2026-09-06 18:57:47 +03:00
parent 01c9a24a14
commit 5ed0106784
3 changed files with 24 additions and 3 deletions
+5 -2
View File
@@ -6,8 +6,11 @@
export async function fetchLiveTenders({ refresh = false } = {}) {
const res = await fetch(`/api/tenders${refresh ? '?refresh=1' : ''}`);
if (!res.ok) throw new Error(`API hatası: HTTP ${res.status}`);
const data = await res.json();
const data = await res.json().catch(() => ({}));
if (!res.ok) {
if (data.code === 'SOURCE_UNAVAILABLE' && data.retryable) throw new Error('İhale kaynağı geçici olarak erişilemiyor. Birkaç dakika sonra yeniden deneyin.');
throw new Error(`API hatası: HTTP ${res.status}`);
}
if (!data.success) throw new Error(data.error || 'API başarısız yanıt döndü');
return data;
}