I have a following code where I want to store the place_id in a variable outside googleMapsClient? But I don't get the desired value.
// Create client with a Promise constructor
const googleMapsClient = require('@google/maps').createClient({
key: 'KEY',
Promise: Promise // 'Promise' is the native constructor.
});
var place_id;
place_id = function () {
return googleMapsClient.places({
query: '1600 Amphitheatre Parkway, Mountain View, CA'
}).asPromise()
.then((response) => {
place_id = response.json.results[0].place_id;
})
.catch((err) => {
place_id = err;
});
};
console.dir(place_id);
Output:
[Function: place_id]
Can anyone help me with this?