Add temporarily console.log statements to debug failed API call

- in production environment, the user locationName is updated, but it is
failing the `createOrUpdateLocations` function in backend/src/middleware/nodes/locations.js
For some reason, it seems like the API call is coming back with
something other than what we are looking for.
Need help debugging... we can remove this code after we figure out
what's wrong
This commit is contained in:
mattwr18 2019-09-09 12:53:47 +02:00
parent e819ade8cb
commit 2aef2add3d
2 changed files with 16 additions and 12 deletions

View File

@ -59,13 +59,21 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
if (isEmpty(locationName)) {
return
}
const res = await fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
locationName,
)}.json?access_token=${CONFIG.MAPBOX_TOKEN}&types=region,place,country&language=${locales.join(
',',
)}`,
)
let res
try {
res = await fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
locationName,
)}.json?access_token=${
CONFIG.MAPBOX_TOKEN
}&types=region,place,country&language=${locales.join(',')}`,
)
/* eslint-disable-next-line no-console */
console.log('res', res)
} catch (error) {
/* eslint-disable-next-line no-console */
console.log('error', error)
}
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({
@ -175,10 +175,6 @@ export default {
.then(res => {
this.cities = this.processCityResults(res)
})
.catch(error => {
/* eslint-disable-next-line no-console */
console.log(error)
})
.finally(() => {
this.loadingGeo = false
})