Skip to content

Commit 3b9e8f1

Browse files
committed
fix: fallback to mock products if API returns empty array (newly initialized database)
1 parent 575e979 commit 3b9e8f1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/services/api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ export const apiService = {
7575

7676
const data = await response.json() as ApiProductSummary[];
7777

78+
if (!data || data.length === 0) {
79+
console.warn('Veritabanında ürün bulunamadı, mock veriler kullanılıyor.');
80+
return searchAndSimulateProducts(filters.query || '', filters.category || 'all');
81+
}
82+
7883
// Gelen veriyi Expo modeline uyarla
7984
return data.map((item: ApiProductSummary): Product => {
8085
const pricesObj: Record<string, number | null> = {

0 commit comments

Comments
 (0)