In short
Your first app that talks to a real API. Type a city, fetch live weather, show it nicely, and handle the moment someone types "Banglore" by mistake.
A weather app that fetches live data for any city from a public weather API and shows the temperature, conditions and an icon.

Think of it like this
Calling mausi in Chennai
You call your mausi and ask, "Baarish ho rahi hai?". You ask (the request), wait while she looks outside (loading), and she tells you, or the call drops (error). A weather app makes that same call to a weather server, for any city.
Watch it happen
getWeather("Pune")
GET /search?name=Pune
1/6First, turn the city name into coordinates.
The big ideas
What you need to know
fetch with async/await
Two calls: city name to coordinates, then coordinates to weather. Await each, and check res.ok.
Three screen states
Loading, error and success. Each one needs its own message on screen, not just a console log.
API keys aren't secret in the browser
Any key in frontend code is visible to users. Fine for practice, but real apps call the API from a server.
Start with Open-Meteo
It has free geocoding and forecast APIs that need no key, so you can focus on the code.
How it works
Build plan
- 1
Search form
An input and a button, plus an area for the result.
- 2
City to coordinates
Call the geocoding API with the city name and take the first match.
- 3
Fetch the weather
Call the forecast API with that latitude and longitude.
- 4
Show it
Render temperature and place name, with a simple icon.
- 5
Handle the bad days
Loading text, "City not found", and network errors.
See it in code
Walk through the code
1async function getWeather(city) {2 const geoUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(city)}&count=1`;3 const geo = await fetch(geoUrl).then((r) => r.json());4 if (!geo.results?.length) throw new Error("City not found");5 6 const { latitude, longitude, name } = geo.results[0];7 const url = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m`;8 const data = await fetch(url).then((r) => r.json());9 return `${name}: ${data.current.temperature_2m}°C`;10}11 12getWeather("Pune")13 .then(console.log) // e.g. "Pune: 29.4°C"14 .catch((err) => console.log(err.message));1/4Look up the city. Optional chaining avoids a crash when results are missing.
encodeURIComponent makes city names with spaces, like "New Delhi", safe to put in a URL. ?. stops the crash when no results come back.
Save yourself the pain
Common mistakes
Oops
Pushing a paid API key to a public GitHub repo.
Do this instead
Bots scan GitHub for keys. Use a key-free API for practice, or keep the key on a server and call that.
Oops
Showing nothing while the request runs.
Do this instead
Show "Loading..." or a spinner, and disable the button so it isn't clicked five times.
Oops
Assuming every search returns a city.
Do this instead
Check the results exist before reading them and show a friendly "City not found".
Your mission
Milestone 1: one city, one number
Quick check
Your fetch call gets a 404 response from the server. What does the fetch promise do?
Go deeper
- 1Show clear loading and error states, including for a misspelt city.
- 2Remember the last searched city using localStorage.
- 3Add a button that uses the browser's location to show local weather.
Also part of these roadmaps
More projects at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.