I'm going nuts, I don't know why this doesn't work and returns a 404 error, here is the code :
app.get('/tasks/today', (req, res) => {
const today = new Date().toISOString().slice(0, 10);
db.all('SELECT * FROM tasks WHERE startDate = ?', [today], (err, tasks) => {
if (err) {
console.error(err.message);
res.status(500).json({ error: 'Internal Server Error' });
} else {
res.json(tasks);
}
});
});
Like the other endpoints (Get task by id works great), I expected this to work just fine
I fixed the problem, the order of the endpoints caused the issue, after putting this endpoint before /tasks/:id it worked, I think the api treated /today as /:id and it returned nothing