Back End Development and APIs Projects - Exercise Tracker test case #8

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

The user id is not on the body payload, it is in the params.

Not sure I understand - the user id is passed to the html form and should be available in the body right?

No, the id is in the params, the body payload only contains the description, duration, and date payload.

You can also use the browser network tab when you submit to see the request/response.

If you look at the HTML you can see there is a script as part of the form submit.

Thanks, that makes a bit more sense looking at the HTML script.