I'm having problems with google maps place details API.
this is my request:
I get the right response with all the fields I requested but when I try to read the value of location inside geometry I get this error:
TypeError: Cannot read property 'location' of undefined
How I try to extract the location parameter:
data["geometry"]["location"]
Any help would be appreciated, thanks!
{
"html_attributions" : [],
"result" : {
"formatted_address" : "Level 1, 2 and 3, Overseas Passenger Terminal, Circular Quay W, The Rocks NSW 2000, Australia",
"formatted_phone_number" : "(02) 9251 1188",
"geometry" : {
"location" : {
"lat" : -33.85873230000001,
"lng" : 151.2100055
},
"viewport" : {
"northeast" : {
"lat" : -33.8573990197085,
"lng" : 151.2112270302915
},
"southwest" : {
"lat" : -33.86009698029149,
"lng" : 151.2085290697085
}
}
},
"name" : "Cruise Bar",
"rating" : 4
},
"status" : "OK"
}
CodePudding user response:
data["geometry"]["location"]
probably needs to be
data["result"]["geometry"]["location"]
assuming data is the JSON parsed body.
