const maps = new Client({});
const geocode = async (address: string) => {
const res = await maps.geocode({
params: {
address,
key: `${process.env.GOOGLE_MAPS_API_KEY}`,
},
timeout: 1000, // milliseconds
});
if (res.status < 200 || res.status > 299 ) {
throw new Error(res.data.error_message);
}
return res.data.results[0]..address_components;
},