Merge branch 'master' of github.com:Human-Connection/Human-Connection into 1488-filter-posts-by-emotion

This commit is contained in:
mattwr18 2019-09-09 16:59:35 +02:00
commit ba3e0ca941
2 changed files with 7 additions and 2 deletions

View File

@ -1,9 +1,12 @@
import request from 'request'
import { UserInputError } from 'apollo-server'
import isEmpty from 'lodash/isEmpty'
import Debug from 'debug'
import asyncForEach from '../../helpers/asyncForEach'
import CONFIG from './../../config'
const debug = Debug('human-connection:location')
const fetch = url => {
return new Promise((resolve, reject) => {
request(url, function(error, response, body) {
@ -59,6 +62,7 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
if (isEmpty(locationName)) {
return
}
const res = await fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
locationName,
@ -67,6 +71,8 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
)}`,
)
debug(res)
if (!res || !res.features || !res.features[0]) {
throw new UserInputError('locationName is invalid')
}

View File

@ -101,7 +101,7 @@ export default {
async submit() {
this.loadingData = true
const { name, about } = this.formData
let { locationName } = this.formData
let { locationName } = this.formData || this.currentUser
locationName = locationName && (locationName['label'] || locationName)
try {
await this.$apollo.mutate({
@ -159,7 +159,6 @@ export default {
this.cities = []
return
}
this.loadingGeo = true
this.axiosSource = CancelToken.source()