goinaction / code

Source Code for Go In Action examples
4.14k stars 2.38k forks source link

The #180

Open XRIDER123 opened 4 months ago

XRIDER123 commented 4 months 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); } }