Created
February 8, 2025 21:45
-
-
Save tomfordrumm/338502cd6f43b4f1c5ee65b2d96b0c76 to your computer and use it in GitHub Desktop.
Example of openweathermap.org api call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lat = 40.7128; // Широта, например, Нью-Йорк | |
const long = -74.0060; // Долгота, например, Нью-Йорк | |
const apiKey = 'your_api_key_here'; // Ваш API-ключ | |
fetch(`https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${long}&appid=${apiKey}`) | |
.then(response => { | |
if (!response.ok) { | |
throw new Error(`HTTP error! Status: ${response.status}`); | |
} | |
return response.json(); | |
}) | |
.then(data => { | |
console.log('Weather data:', data); | |
}) | |
.catch(error => { | |
console.error('Error fetching weather data:', error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment