async function getCurrentConditions()

in samples-js/functions/weatherMonitor.js [90:102]


async function getCurrentConditions(location) {
    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 = await axios.get(url);
        return response.data.weather[0];
    } catch (err) {
        throw err;
    }
}