Semester: S3
Course: Advanced Web Development
Course code: PROG_WEB2
A vanilla JavaScript application for managing user data with real-time updates and no page refreshes.
- Fetch & Display Users: Retrieves user data from a REST API and displays them in a card-based layout
- Live Updates: Edit user information with changes reflected instantly without page reload
- Responsive Design: Built with Bootstrap 5 for a mobile-friendly interface
- Loading States: Visual feedback with spinners during data operations
- Error Handling: Comprehensive error messages for failed operations
- Modal-Based Editing: Clean user editing interface using Bootstrap modals
- Edit functionality works with live updates
- Responsive design tested on mobile and desktop
- No page refreshes when editing users
- Vanilla JavaScript (ES6+ modules)
- HTML5 for structure
- Bootstrap 5.3.8 for styling and components
- Fetch API for HTTP requests
- CSS3 for custom styling and animations
βββ index.html
βββ scripts/
β βββ script.js
β βββ mock-data/
β | βββ response.json
β |
β βββ modules/
β βββ fetchData.js
β βββ formFactory.js
β βββ putData.js
The application connects to: https://easy-simple-users-rest-api.onrender.com/api/users
Content-Type: application/jsonmy_key: my_super_secret_phrase
User Data Structure:
{
id: number,
name: string,
age: number,
avatar_url: string,
gender: string
}- Initial Load: Fetches all users from the API and displays them as cards
- Edit User: Click the "Edit" button on any user card to open a modal with a pre-filled form
- Update: Modify user details and click "Save changes"
- Live Refresh: The user card updates immediately with the new data
- Clone or download the project
- Ensure all files maintain the directory structure shown above
- Open index.html in a modern web browser
- No build process or npm installation required!
loadData(): Fetches users from the APIdisplayUsers(): Renders user cards to the DOMmodalConstruction(): Attaches edit functionality to buttons and contructs modal functionalityupdateCard(): Updates the UI after successful PUT HTTP method sent to APIformFactory(): Dynamically generates the edit formputData(): Sends PUT requests to fully update user data
Requires a modern browser with support for:
- Fetch API
- ES6+ modules
- HTML5
- CSS3
- Bootstrap 5.3.8
- CSS Grid/Flexbox
The application includes error handling for:
- Failed API requests
- Network errors
- Invalid responses
- Missing data