javascript
api-fetch apiurl weather-information openweathermap-api apikey city
Published on January 26, 2024By DeveloperBreeze
const apiKey = 'YOUR_API_KEY';
const city = 'New York';
const apiUrl = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apiKey}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => console.log('Weather Information:', data))
.catch(error => console.error('Error:', error));
Comments
Please log in to leave a comment.