Learning is not always easy, but it is always rewarding 💪 This repository contains a complete implementation of Homework 11, focused on working with HTTP requests, backend APIs, and dynamic UI updates.
In Module 11, the focus shifts to understanding how frontend applications communicate with backend services using HTTP.
This homework helps reinforce your knowledge of:
- The difference between HTTP and HTTPS
- Basic HTTP methods (
GET,POST,PUT,PATCH,DELETE) - The concept of CRUD operations
- How frontend applications interact with backend APIs
- Handling asynchronous HTTP requests with JavaScript
It’s time to put this knowledge into practice by building an image search application that communicates with a real backend service.
goit-js-hw-11/ ├─ src/ │ ├─ js/ │ │ └─ gallery.js │ ├─ styles/ │ │ └─ loader.css │ ├─ index.html │ └─ main.js ├─ public/ ├─ dist/ ├─ package.json ├─ vite.config.js └─ README.md
The project is bundled using Vite and follows a clean, scalable structure.
The goal of this task is to create an application that allows users to search for images by keyword and display the results in a gallery.
The application includes a search form where the user enters a keyword. When the form is submitted, an HTTP request is sent to the backend using the entered term.
- User enters a search query
- Form submission triggers an HTTP request
- Previous search results are cleared before a new request
The backend service used in this project is the public Pixabay API. Each request includes required query parameters to ensure correct results.
key— personal API access keyq— search keyword entered by the userimage_type=photoorientation=horizontalsafesearch=true
If the backend returns an empty array, a notification is shown informing the user that no matching images were found.
Search results are rendered inside a gallery container. Each image card is created dynamically based on the backend response.
webformatURL— small image for gallery viewlargeImageURL— large image for modal viewtags— image description (used asalttext)likesviewscommentsdownloads
Before starting a new search, the gallery is completely cleared to avoid mixing results.
To display large versions of images in a modal window, the SimpleLightbox library is used.
import SimpleLightbox from "simplelightbox"; import "simplelightbox/dist/simple-lightbox.min.css";
- Each image card is wrapped in a link element
- Clicking an image opens it in a modal
- After adding new images to the DOM,
refresh()is called
A loading indicator is displayed while images are being fetched from the backend.
- Loader appears before the HTTP request starts
- Loader disappears after the response is received
- A CSS loader library is used for better UX
User notifications are displayed using the iziToast library instead of alerts.
import iziToast from "izitoast"; import "izitoast/dist/css/iziToast.min.css";
Notifications are shown when:
- No images are found for the search query
- An error occurs during the HTTP request
All HTTP requests are handled using Promise chains with
then() and catch() to prevent application crashes.
- Errors are caught and handled gracefully
- The UI remains stable even if the request fails
- The homework submission includes GitHub repository and live page links
- The project is built using Vite
- No console errors, warnings, or logs are present
- iziToast, SimpleLightbox, and css-loader libraries are installed
- The UI matches the provided layout or custom styling
- A search form is available on the page
- Loader appears before the request and disappears after response
- Previous results are cleared before a new search
- HTTP requests include required query parameters
- Images are rendered based on backend response
- DOM updates are performed in a single operation
- SimpleLightbox
refresh()is called after rendering - Clicking an image opens it in a modal window
- Errors are handled using
then()andcatch()
This project demonstrates practical skills in working with HTTP requests, backend APIs, and dynamic user interfaces.
It reflects a real-world frontend workflow using:
- Asynchronous JavaScript
- REST APIs
- Third-party libraries
- Modern build tools
- GitHub Repository: https://github.com/USERNAME/goit-js-hw-11
- Live Demo (GitHub Pages): https://USERNAME.github.io/goit-js-hw-11/