I am having issues with the fourth exercise, the post request in the /api/users/:_id/exercises route in the exercise tracker project

Tell us what’s happening:
Describe your issue in detail here.
I am getting the required output when i tested with postman but its not passing the test
Your project link(s)

solution: https://replit.com/@maytheu/boilerplate-project-exercisetracker

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Exercise Tracker

Link to the challenge:

res.send({ username: user.username, duration, description, date: doc.date.toDateString(), _id: user._id });

You could try to use res.json() instead. So it will be treated as a json object, that could be the problem, I could not see any error in my browser console when I run the tests. but it does not pass as you say

thanks for your response, the test still fails after changing it to res.json

The challenge description doesn’t explicitly mention it, but the duration needs to be of type Number, you’ve declared it as String.

Tried your suggestion but the test still fails :unamused:

Update
So after defining the type in schema, it turns out that duration is still a string. I had to force the duration to number after the user input

Let duration = Number(req.body.duration)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.