From 912121cf0927a1c0642f89a88dfc95652e428d23 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Tue, 21 Apr 2026 13:17:49 +0700 Subject: [PATCH] fix(web): unwrap {data} envelope in getNeighborhoodScore (TEC-3093) apiClient.get returns the raw JSON body { data, cacheMeta }, so callers were storing the envelope in state and reading totalScore as undefined, crashing ListingDetailClient via undefined.toFixed(1). Unwrap .data inside getNeighborhoodScore so consumers receive the bare NeighborhoodScoreResult as the existing type expects. Co-Authored-By: Paperclip --- apps/web/lib/listings-api.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/lib/listings-api.ts b/apps/web/lib/listings-api.ts index 6f47fe6..6f2d44e 100644 --- a/apps/web/lib/listings-api.ts +++ b/apps/web/lib/listings-api.ts @@ -298,7 +298,9 @@ export const listingsApi = { apiClient.get(`/listings/${listingId}/similar?limit=${limit}`), getNeighborhoodScore: (district: string, city: string = 'Hồ Chí Minh') => - apiClient.get( - `/analytics/neighborhoods/${encodeURIComponent(district)}/score?city=${encodeURIComponent(city)}`, - ), + apiClient + .get<{ data: NeighborhoodScoreResult }>( + `/analytics/neighborhoods/${encodeURIComponent(district)}/score?city=${encodeURIComponent(city)}`, + ) + .then((res) => res.data), };