From ba14181bdda0e1f2080409a2246ed8fd10f450d7 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Fri, 10 Mar 2023 23:36:45 +0100 Subject: [PATCH] Adding a test for undefined addresses --- src/lib/osm.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/osm.ts b/src/lib/osm.ts index f271a35..69cab71 100644 --- a/src/lib/osm.ts +++ b/src/lib/osm.ts @@ -36,8 +36,10 @@ export const getVillageOrTown = (address: any) => { 'locality', ]; + if (!address || !address.address) return ''; + for (let synonym of citySynonyms) { - // console.log({ caller: 'getVillageOrTown', address, synonym }); + // console.log({ caller: 'getVillageOrTown', address, synonym }); if (synonym in address?.address) { return address?.address[synonym]; }