Skip to content

Commit

Permalink
Fix error with search results because of namedetails suddenly being null
Browse files Browse the repository at this point in the history
  • Loading branch information
cdauth committed Sep 13, 2023
1 parent 0649318 commit 99f23af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface NominatimResult {
lat: string;
lon: string;
zoom?: number;
name: string;
display_name: string;
place_rank: number;
category: string;
Expand All @@ -29,7 +30,7 @@ interface NominatimResult {
address: Partial<Record<string, string>>;
geojson: Geometry;
extratags: Record<string, string>;
namedetails: Record<string, string>;
namedetails: Record<string, string> | null;
elevation?: number; // Added by us
}

Expand Down Expand Up @@ -230,7 +231,7 @@ function _formatAddress(result: NominatimResult) {
// address notation guidelines

let type = result.type;
let name = result.namedetails.name;
let name = result.namedetails?.name ?? result.name;
const countryCode = result.address.country_code;

let road = result.address.road;
Expand Down

0 comments on commit 99f23af

Please sign in to comment.