diff --git a/backend/src/schema/resolvers/users/location.js b/backend/src/schema/resolvers/users/location.js index 70372e548..affd3267e 100644 --- a/backend/src/schema/resolvers/users/location.js +++ b/backend/src/schema/resolvers/users/location.js @@ -137,11 +137,12 @@ const createOrUpdateLocations = async (userId, locationName, session) => { }) } -export const queryLocations = async ({place, lang}) => { - const res = await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${place}.json?access_token=${CONFIG.MAPBOX_TOKEN}&types=region,place,country&language=${lang}`) - console.log(res) +export const queryLocations = async ({ place, lang }) => { + const res = await fetch( + `https://api.mapbox.com/geocoding/v5/mapbox.places/${place}.json?access_token=${CONFIG.MAPBOX_TOKEN}&types=region,place,country&language=${lang}`, + ) + // Return empty array if no location found or error occurred if (!res || !res.features) { - // Return empty array if no location found or error occurred return [] } return res.features diff --git a/webapp/graphql/location.js b/webapp/graphql/location.js index ba47a2983..0fa2c2a2d 100644 --- a/webapp/graphql/location.js +++ b/webapp/graphql/location.js @@ -7,4 +7,4 @@ export const queryLocations = () => gql` id } } -` \ No newline at end of file +` diff --git a/webapp/pages/settings/index.vue b/webapp/pages/settings/index.vue index be1c4800f..3b532fc42 100644 --- a/webapp/pages/settings/index.vue +++ b/webapp/pages/settings/index.vue @@ -147,8 +147,10 @@ export default { const place = encodeURIComponent(value) const lang = this.$i18n.locale() - const { data: { queryLocations: res }} = await this.$apollo.query({ query: queryLocations(), variables: { place, lang } }) - + const { + data: { queryLocations: res }, + } = await this.$apollo.query({ query: queryLocations(), variables: { place, lang } }) + this.cities = this.processLocationsResult(res) this.loadingGeo = false },