Backend: ensure PaginatedPlaces.Data is never nil (return empty slice) Frontend: defensive fallback res.data || []
@@ -157,6 +157,10 @@ func (h *PlaceHandler) ListMy(w http.ResponseWriter, r *http.Request) {
return
}
+ if places.Data == nil {
+ places.Data = []*models.Place{}
+ }
+
writeJSON(w, http.StatusOK, places)
@@ -265,7 +265,7 @@ export default function MyPlacesPage() {
const fetchPlaces = () => {
setLoading(true)
api.get<{ data: Place[] }>('/places/my')
- .then((res) => setPlaces(res.data))
+ .then((res) => setPlaces(res.data || []))
.catch(() => {})
.finally(() => setLoading(false))