const res = await fetch(
'https://api.weather.gov/gridpoints/TOP/31,80/forecast',
{ headers: { 'User-Agent': 'MyApp (contact@example.com)' } }
);
const { periods } = (await res.json()).properties;
periods.slice(0, 3).forEach(p =>
console.log(`${p.name}: ${p.temperature}°${p.temperatureUnit} — ${p.shortForecast}`)
);const res = await fetch(
'https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t=temperature_2m,wind_speed_10m'
);
const { current } = await res.json();
console.log(`Berlin: ${current.temperature_2m}°C, wind ${current.wind_speed_10m} km/h`);const res = await fetch(
`https://api.openweathermap.org/data/2.5/weather?q=London&appid=${process.env.OWM_API_KEY}&units=metric`
);
const data = await res.json();
console.log(`${data.name}: ${data.main.temp}°C, ${data.weather[0].description}`);const res = await fetch(
`https://api.tomorrow.io/v4/weather/realtime?location=new york&apikey=${process.env.TOMORROW_API_KEY}`
);
const { data: { values } } = await res.json();
console.log(`New York: ${values.temperature}°C, humidity ${values.humidity}%, wind ${values.windSpeed} m/s`);const res = await fetch(
`https://api.weatherapi.com/v1/current.json?key=${process.env.WEATHERAPI_KEY}&q=Seoul`
);
const { location, current } = await res.json();
console.log(`${location.name}: ${current.temp_c}°C, ${current.condition.text}`);const res = await fetch(
`https://api.weatherbit.io/v2.0/current?city=London&key=${process.env.WEATHERBIT_KEY}`
);
const { data: [w] } = await res.json();
console.log(`${w.city_name}: ${w.temp}°C, ${w.weather.description}`);