A movie search app is the perfect second project after a to-do list. It teaches you the skill every real app needs: talking to an API, waiting for the answer, and showing the result. Here is a complete version you can build in an afternoon.
The plan
- An input where the user types a movie name.
- A
fetchcall to a movie API (OMDb has a free tier) when they search. - A grid of cards showing the poster, title, and year.
- A friendly message when nothing is found.
The HTML
<input id="search" type="text" placeholder="Search a movie..."> <button id="btn">Search</button> <div id="results"></div> The JavaScript
const API_KEY = 'YOUR_OMDB_KEY'; async function searchMovies(query) { const res = await fetch( `https://www.omdbapi.com/?apikey=${API_KEY}&s=${encodeURIComponent(query)}` ); const data = await res.json(); return data.Search || []; } function showMovies(movies) { const box = document.getElementById('results'); if (movies.length === 0) { box.innerHTML = '<p>No movies found. Try another title.</p>'; return; } box.innerHTML = movies.map(m => ` <div class="card"> <img src="${m.Poster !== 'N/A' ? m.Poster : 'placeholder.jpg'}" alt="${m.Title}"> <h3>${m.Title}</h3> <p>${m.Year}</p> </div> `).join(''); } document.getElementById('btn').addEventListener('click', async () => { const query = document.getElementById('search').value.trim(); if (!query) return; const movies = await searchMovies(query); showMovies(movies); }); Three details beginners miss
- Always
encodeURIComponentthe query. A movie like "Fast & Furious" breaks your URL without it. - Handle the
N/Aposter. Some movies have no poster, and a broken image icon looks worse than a placeholder. - Show a loading state. Set the results area to "Searching..." before the
fetch, so the user knows the app heard them.
What to add next
Click a card to fetch the full plot and rating with a second API call, save favourites to localStorage, or add a debounce so the search runs as the user types. Each of those is one small feature — and each one teaches you something a tutorial alone never will.