Looking for a mix design?
console.log('Weather script running for Volume Concrete');
const apiKey = '4827d7ceb7afc7af5cd7c65aab9f3ee3'; // Replace with your OpenWeatherMap API key
const city = 'Portland,OR,US';
const apiUrl = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apiKey}&units=imperial`;
async function fetchWeather() {
const weatherBox = document.getElementById('weather-box');
if (!weatherBox) {
console.error('Weather box element not found');
return;
}
try {
const response = await fetch(apiUrl);
if (!response.ok) {
const errorData = await response.json();
throw new Error(`API Error: ${errorData.message}`);
}
const data = await response.json();
weatherBox.innerHTML = `
Temperature: ${data.main.temp.toFixed(1)}°F
Condition: ${data.weather[0].description}
Humidity: ${data.main.humidity}%
Wind Speed: ${data.wind.speed} mph
`;
} catch (error) {
weatherBox.innerHTML = `Error: ${error.message}
`;
console.error('Fetch error:', error);
}
}
document.addEventListener('DOMContentLoaded', () => {
console.log('DOM loaded, fetching weather');
fetchWeather();
});
setInterval(fetchWeather, 3600000); // Update hourly