in samples-ts/functions/weatherMonitor.ts [124:136]
async function getCurrentConditions(location: Location): Promise<WeatherData> {
try {
// get current conditions from OpenWeatherMap API
const url = location.state
? `https://api.openweathermap.org/data/2.5/weather?q=${location.city},${location.state},${location.country}&appid=${process.env.OpenWeatherMapApiKey}`
: `https://api.openweathermap.org/data/2.5/weather?q=${location.city},${location.country}&appid=${process.env.OpenWeatherMapApiKey}`;
const response: WeatherApiResponse = await axios.get(url);
return response.data.weather[0];
} catch (err) {
throw err;
}
}