Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.5.4: findPlace "cannot read property 'split' of undefined" #182

Closed
econner opened this issue Jul 17, 2018 · 2 comments
Closed

Comments

@econner
Copy link

econner commented Jul 17, 2018

Hello,

I am getting the following error when trying to use findPlace with version 0.5.4 of this library:

TypeError: Cannot read property 'split' of undefined
    at /node_modules/@google/maps/lib/apis/places.js:58:37
    at /node_modules/@google/maps/lib/internal/validate.js:168:15
    at Array.forEach (native)
    at Object.validator (/node_modules/@google/maps/lib/internal/validate.js:167:16)
    at Object.findPlace (/node_modules/@google/maps/lib/index.js:55:25)

I am calling this method like so:

const results = await googleMapsClient.findPlace({
      input: query, 
      inputtype: 'textquery',
      fields: ['formatted_address','icon','photos','name','place_id'],
    })
    .asPromise()
    .then((response) => {
      return response.json.candidates
    })

I tracked it down and found that findPlace now expects a locationbias parameter that needs to be a string on line 58 of places.js (because split is called on it):

var parts = query.locationbias.split(':');

I was able to solve my problem by passing an empty string for locationbias:

const results = await googleMapsClient.findPlace({
      input: query, 
      inputtype: 'textquery',
      fields: ['formatted_address','icon','photos','name','place_id'],
      locationbias: ""
    })
    .asPromise()
    .then((response) => {
      return response.json.candidates
    })

But my guess is that locationbias should be optional rather than needing to pass an empty string.

@stephenmcd
Copy link
Contributor

Thanks for the report - I just pushed a new version 0.5.5 with a fix.

@econner
Copy link
Author

econner commented Jul 18, 2018

Thanks for the quick fix. I'll test it and follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants