handle bizzarities
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
22c5c996303fb0771ac8e98dc1ecb867d89a486f- Parents
-
21413ac - Tree
abcf9a8
22c5c99
22c5c996303fb0771ac8e98dc1ecb867d89a486f21413ac
abcf9a8| Status | File | + | - |
|---|---|---|---|
| M |
frontend/lib/api.ts
|
14 | 5 |
frontend/lib/api.tsmodified@@ -90,12 +90,21 @@ export const restaurantApi = { | ||
| 90 | 90 | return response.data; |
| 91 | 91 | }, |
| 92 | 92 | |
| 93 | - // Search places | |
| 93 | + // Search places - FIXED to handle 404 with data | |
| 94 | 94 | searchPlaces: async (lat: number, lng: number, radius: number = 1000) => { |
| 95 | - const response = await api.get<PlaceSearchResult[]>('/search/places/', { | |
| 96 | - params: { lat, lng, radius } | |
| 97 | - }); | |
| 98 | - return response.data; | |
| 95 | + try { | |
| 96 | + const response = await api.get<PlaceSearchResult[]>('/search/places/', { | |
| 97 | + params: { lat, lng, radius } | |
| 98 | + }); | |
| 99 | + return response.data; | |
| 100 | + } catch (error: any) { | |
| 101 | + // Handle the bizarre 404-with-data issue from Railway | |
| 102 | + if (error.response?.status === 404 && Array.isArray(error.response?.data)) { | |
| 103 | + console.warn('Got 404 with valid data - returning data anyway'); | |
| 104 | + return error.response.data; | |
| 105 | + } | |
| 106 | + throw error; | |
| 107 | + } | |
| 99 | 108 | }, |
| 100 | 109 | |
| 101 | 110 | // Seed data |