end of class
This commit is contained in:
@@ -12,6 +12,51 @@ app.get("/test", async (req, res) => {
|
||||
res.send("Hello World!");
|
||||
});
|
||||
|
||||
const tasks = [
|
||||
{
|
||||
id: 1,
|
||||
completed: false,
|
||||
title: "Buy groceries for the week",
|
||||
description: "Pick up vegetables, fruits, milk, eggs, and bread from the supermarket.",
|
||||
dueDate: "14/03/2026",
|
||||
dateCreated: new Date(Date.now()).toLocaleDateString("en-AU")
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
completed: false,
|
||||
title: "Clean the apartment",
|
||||
description: "Vacuum the floors, wipe kitchen surfaces, and take out the trash.",
|
||||
dueDate: "16/03/2026",
|
||||
dateCreated: new Date(Date.now()).toLocaleDateString("en-AU")
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
completed: false,
|
||||
title: "Call the dentist for appointment",
|
||||
description: "Book a routine checkup and confirm available time slots for next week.",
|
||||
dueDate: "17/03/2026",
|
||||
dateCreated: new Date(Date.now()).toLocaleDateString("en-AU")
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
completed: true,
|
||||
title: "Do laundry and fold clothes",
|
||||
description: "Wash dark and light loads separately, then fold and organize clean clothes.",
|
||||
dueDate: "21/03/2026",
|
||||
dateCreated: new Date(Date.now()).toLocaleDateString("en-AU")
|
||||
}
|
||||
];
|
||||
|
||||
app.get("/api/tasks", async (req, res) => {
|
||||
try {
|
||||
res.json(tasks);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Error: ${error}`)
|
||||
res.status(500).json({ message: "Error getting tasks" })
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`To Do App listening on port ${port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user