goinaction / code

Source Code for Go In Action examples
4.12k stars 2.36k forks source link

The #180

Open XRIDER123 opened 1 month ago

XRIDER123 commented 1 month ago

const API_KEY = 'YOUR_API_KEY'; const API_URL = 'https://api.openweathermap.org/data/2.5/weather?q=';

async function fetchWeather(location) { try { const response = await fetch(${API_URL}${location}&appid=${API_KEY}&units=metric); const data = await response.json(); console.log(data); return data; } catch (error) { console.error('Error fetching weather data:', error); } }