Mini project
Weather Dashboard with JavaScript and a Free API
A weather web app where users search any city and see current conditions and a 7-day forecast, built with fetch and async/await on a free weather API that needs no key.
HTMLCSSJavaScriptFetch APIOpen-Meteo API
The problem
Real apps get their data from APIs. A weather dashboard is a good first API project: the data changes every day, the results are easy to check, and it covers loading states, errors and turning JSON into a page.
Open-Meteo offers free forecast and geocoding APIs for non-commercial use without an API key, so you can start without signing up. Read its terms before you publish your app.
Features to build
- Search a city by name and turn it into coordinates with a geocoding API
- Show current temperature, weather condition and wind speed
- Show a 7-day forecast with minimum and maximum temperatures
- A loading message while data is fetched
- A clear message when the city is not found or the network fails
- Remember recent searches with localStorage
- Turn weather codes into readable text and icons
Build plan
- 1
Read the API documentation
Find the geocoding endpoint that returns latitude and longitude for a city name, and the forecast endpoint with current and daily parameters. Try both URLs in the browser first.
- 2
Build the layout
Write a search form, a current weather card and a forecast row, with placeholder content.
- 3
Fetch the data
Write an async function that calls the geocoding API, then the forecast API with the coordinates, using await response.json().
- 4
Handle errors
Check response.ok, handle a search with no results, and wrap the calls in try and catch to show a friendly message.
- 5
Render the results
Build the cards from the JSON with document.createElement or template literals, and map weather codes to text.
- 6
Recent searches and publishing
Save the last five cities with localStorage, then publish on GitHub Pages and credit the data source on the page.
Learn these first
Each part of the project is taught in one of these free lessons.
- Fetching Data from APIs with JavaScript fetch()
- JavaScript async and await: Writing Asynchronous Code That Reads Like Synchronous Code
- JavaScript Promises: then, catch, finally, Chaining and Promise.all
- JavaScript Error Handling: try, catch, finally, throw and Custom Errors
- JSON in JavaScript: JSON.stringify, JSON.parse and Common Pitfalls
- Changing the DOM: textContent, innerHTML, Attributes, classList and Styles
- Handling Forms with JavaScript: submit, preventDefault, FormData and Validation
- localStorage and sessionStorage in JavaScript: Saving Data in the Browser
Make it stand out
- Use the browser's location with navigator.geolocation
- Switch between Celsius and Fahrenheit
- An hourly temperature chart for today
- Cache responses for a few minutes to avoid repeated requests
Viva and interview questions
Try to answer each one aloud before you open it.
What does async/await do in your code?
awaitpauses the async function until the fetch promise settles, without blocking the page. It lets me write the two API calls in order, like normal code, instead of chaining.then.Does fetch throw an error for a 404 response?
No. fetch only rejects on network failures. For HTTP errors I check
response.okand throw my own error when it is false.Why do you need two API calls?
The forecast API works with latitude and longitude. The geocoding API turns the city name the user types into those coordinates first.
What is JSON?
A text format for data made of objects, arrays, strings, numbers, booleans and null.
response.json()parses it into JavaScript objects.How would you avoid calling the API too often?
Cache each result with the time it was fetched, for example in localStorage, and reuse it if it is only a few minutes old.
What to put in your project report
- Abstract: the problem, your solution and the result in one paragraph.
- Introduction and problem statement: who has the problem and why it matters.
- Requirements: the features (functional) and qualities such as speed and security (non-functional).
- Design: architecture diagram, database tables or data flow, and screen layouts.
- Implementation: the main modules and the most interesting code, explained.
- Testing: the test cases you ran, with inputs, expected and actual results.
- Results: screenshots or numbers that show the project working.
- Conclusion and future scope: what you achieved and what you would add next.
Your college may give its own format. Follow that first, and use this list to check nothing is missing.
More project ideas
- Quiz App with HTML, CSS and JavaScriptMini project
- Snake Game with JavaScript and CanvasMini project
- Typing Speed Test with JavaScriptMini project