I am trying to use place autocomplete on server side with google-maps-services-js. And want to restrict to specific country. For example want to get results only in France. But i cant get the result that i wanted. What am i doing wrong. Here is my code:
const {Client} = require("@googlemaps/google-maps-services-js");
export default async function handler(req, res) {
const client = new Client({});
client
.placeQueryAutocomplete({
params: {
locations: [{ lat: 35.6667, lng: 39.1667}],
key: GOOGLE_MAP_API_KEY,
input: "par",
language: "en",
components:[{'country': "fr"}]
},
timeout: 1000 // milliseconds
})
.then(r => {
res.json(r.data);
})
.catch(e => {
res.json(e);
});
}
Thanks for the help!