My Exercise Tracker program is not able to pass test #10

I am currently finishing the 5th certification (backend and API) projects.
I am working on the 4th Project (Exercise Tracker).

My Program is not able to pass test #10 ( A request to a user’s log GET /api/users/:_id/logs returns a user object with a count property representing the number of exercises that belong to that user.)

When requesting /api/users/:_id/logs , the programs gives exactly the same format that is given by freecodecamp’s proposed app.

But I think the problem is when there are no users with the given id or when there is an error, my result differs with the freecodecamp app one.

I am really not able to detect exactly where the error is.

Here is a link to my program:
C5-P4 - Replit

Note: I have still not implemented the from/to/limit functionalities.

It’s probably not going to pass since you have to implement the POST routes in their entirety for the tests to work properly. When I add some logging to your POST exercise and GET log routes, I get this output when the tests supply a date:

adding exercise for 6235227e00bcf90453b9be54
exercise: {
  "_id": "6235227e00bcf90453b9be54",
  "username": "fcc_test_16476494050",
  "date": "Mon Jan 01 1990",
  "duration": 60,
  "description": "test"

so the record is created. Without a date (like in most tests), I get:

adding exercise for 6235228300bcf90453b9be5a
req.params._id = 6235228300bcf90453b9be5a
  _id: 6235228300bcf90453b9be5a,
  username: 'fcc_test_16476494088',
  count: 0,
  log: []

with no exercise record and an empty log when the test expects a log. On the latter tests with dates provided, I see the log entries.

Logging the date in the POST exercise route confirms this as is undefined and not "" as you test in your conditional to set an empty date.

Instead of testing if is an empty testing, I have tested it if it is either an empty string or undefined if( === "" || "undefined"), and now I have all the tests that concern the /logs working.

Thank you !!!

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