Skip to content

Commit 677d3d4

Browse files
authored
Added some conditions for the town and city data.
1 parent 4b6bdd8 commit 677d3d4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ const getHEREdotcom = async (lat, lon, appid, appcode) => {
144144
here_city = heredotcom.Response.View[0].Result[1].Location.Address.City
145145
here_country = heredotcom.Response.View[0].Result[1].Location.Address.Country
146146

147-
if (here_town == here_city) {
148-
lastRequest.town2 = ""
147+
if (here_town == 'undefined' || here_town == null || here_town == here_city) {
148+
lastRequest.town2 = ""
149149
} else {
150150
lastRequest.town2 = `${here_town} - `
151151
}
@@ -156,7 +156,13 @@ const getHEREdotcom = async (lat, lon, appid, appcode) => {
156156

157157
// Result [1]
158158
lastRequest.city = here_city
159-
lastRequest.city2 = `${here_city}, `
159+
160+
if (here_city == 'undefined' || here_city == null) {
161+
lastRequest.city2 = ""
162+
} else {
163+
lastRequest.city2 = `${here_city}, `
164+
}
165+
160166
lastRequest.state = heredotcom.Response.View[0].Result[1].Location.Address.State
161167
lastRequest.country = heredotcom.Response.View[0].Result[1].Location.Address.Country
162168
lastRequest.country2 = ` - ${here_country}`

0 commit comments

Comments
 (0)