sib
sib

Reputation: 69

Google Maps nearby search returning Invalid_Request

I am trying to connect to google maps using the following url and code to fetch nearby places, but I am getting invalid request. What seems to be the issue here?

let url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=...&location=49.1804488%2C-122.7851227'
let results = await axios.get(url)
console.log(results.data)
console.log(results.status)
console.log(results.error_message)
console.log(results.info_messages)

Upvotes: 1

Views: 859

Answers (2)

Sprint
Sprint

Reputation: 179

For me, I accidentally switched the values for latitude and longitude causing the issue below.

{'html_attributions': [], 'results': [], 'status': 'INVALID_REQUEST'}

I put the correct values then the request succeeded.

Upvotes: 0

geocodezip
geocodezip

Reputation: 161334

The documentation says that only location is required. That seems to be wrong, adding radius to the query returns a result.

This works:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=49.1804488%2C-122.7851227&radius=1500&key=API_KEY

This doesn't work (returns "status" : "INVALID_REQUEST"):

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=49.1804488%2C-122.7851227&key=API_KEY

Upvotes: 4

Related Questions