Tell us what’s happening:
I’m getting an [Error: 404 Not Found]
response from FCC for test case 8. I think it has something to do with cases where there isn’t a valid id passed to the form? Though I’m not sure. Any help is greatly appreciated.
Here is my code for this part of the exercise
app.post('/api/users/:_id/exercises', async (req, res) => {
const update = {
date: req.body.date ?
(new Date(req.body.date)).toDateString() :
(new Date()).toDateString(),
duration: parseInt(req.body.duration),
description: req.body.description
};
var Docs = await Exercise.findOne({_id: req.body[':_id']});
if (Docs != null) {
Docs.log.push(update);
await Docs.save();
res.json({
_id: req.body[':_id'],
username: Docs.username,
date: update.date,
duration: update.duration,
description: update.description
});
} else {
console.log(Docs);
res.json({error: "No ID found"});
}
})
###Your project link(s)
solution: https://jefische-boilerplatepro-o5ea24jj74o.ws-us117.gitpod.io/
githubLink: GitHub - jefische/boilerplate-project-exercisetracker: A boilerplate for a freeCodeCamp project.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Back End Development and APIs Projects - Exercise Tracker