Build a Mini To-Do App Using Your Node.js REST API
Step 0: What We’ll Build
Think of this project like a small kitchen 🍳:
-
Backend (Node.js + SQLite) → your pantry where tasks are stored
-
Frontend (HTML + JavaScript) → your kitchen counter, where you can see and manage your tasks
Our app will allow users to:
-
See a list of tasks
-
Add new tasks
-
Delete tasks
Later, we can also add a “mark as done” feature.
Step 1: Prepare the Frontend
Inside your project folder, create a folder called public and inside it, create index.html and script.js:
Step 2: Create a Simple HTML Layout
Open index.html and add the following code:
Explanation:
-
input→ for typing a new task -
button→ to add the task -
ul#taskList→ where we will display all tasks -
script.js→ handles the JavaScript logic
Step 3: Connect Frontend to Backend
Open script.js and add the following:
Step-by-step explanation:
-
fetchTasks()→ grabs all tasks from backend and displays them -
addTask()→ adds a new task to the backend and refreshes the list -
deleteTask()→ removes a task from the backend and refreshes the list
Step 4: Adjust Your Backend
-
Create a tasks table in your SQLite database:
-
Create a new
routes/tasks.jsfile:
-
Update
server.jsto use the tasks route and serve static frontend:
Step 5: Test Your Mini To-Do App
-
Run your server:
-
Open
http://localhost:3000/in your browser -
Add some tasks → see them appear
-
Delete tasks → see them disappear
Congratulations! 🎉 You now have a mini full-stack To-Do app using Node.js REST API and a simple frontend