Skip to content
Laviyx Learn

Try

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.

Intermediate 1–2 weeks 1 studentUpdated

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. 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. 2

    Build the layout

    Write a search form, a current weather card and a forecast row, with placeholder content.

  3. 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. 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. 5

    Render the results

    Build the cards from the JSON with document.createElement or template literals, and map weather codes to text.

  6. 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.

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?

    await pauses 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.ok and 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

  1. Abstract: the problem, your solution and the result in one paragraph.
  2. Introduction and problem statement: who has the problem and why it matters.
  3. Requirements: the features (functional) and qualities such as speed and security (non-functional).
  4. Design: architecture diagram, database tables or data flow, and screen layouts.
  5. Implementation: the main modules and the most interesting code, explained.
  6. Testing: the test cases you ran, with inputs, expected and actual results.
  7. Results: screenshots or numbers that show the project working.
  8. 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.

All project ideas →