Exercise tracker: Logs endpoint doesn't pass the tests

Hi, I’m having some problems passing the Exercise Tracker backend project, all but the /logs endpoint tests fail, all the other endpoints pass the thest.

These are the thest that fail:

  • 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.

  • Failed:A GET request to /api/users/:_id/logs will return the user object with a log array of all the exercises added.

  • Failed:Each item in the log array that is returned from GET /api/users/:_id/logs is an object that should have a description, duration, and date properties.

  • Failed:The description property of any object in the log array that is returned from GET /api/users/:_id/logs should be a string.

  • Failed:The duration property of any object in the log array that is returned from GET /api/users/:_id/logs should be a number.

  • Failed:The date property of any object in the log array that is returned from GET /api/users/:_id/logs should be a string. Use the dateString format of the Date API.

The thing is, all the expected responses are correct when I test them in my replit, and locally.

Replit link: https://FCC-Excercise-Tracker-API.monkaws624.repl.co

github repo: GitHub - Robertron624/FCC-Excercise-Tracker-API

We really need the link to your repl to fork and run the code so that we can see the errors.

However, you should be able to log the route inputs and outputs to your POST exercises and GET logs routes to diagnose the problem.

Hi, here it’s the replit link: Join Monkaws624's "FCC-Excercise-Tracker-API" - Replit
I also included the GitHub repo, it’s the same code.
I did log the request inputs and the results before they are sent, but to me, they look correct, I don’t know why FCC doesn’t accept them.

Same code, but we can run it on repl.it conveniently.

You really have to log all the route inputs and every possible route response while debugging. Do so yields

POST exercise
req.body: {"description":"test","duration":"60"}
req.params: {"id":"6354560eb0e10b544e5f0c8d"}
req.query: {}
There was an error saving this exercise
GET LOGS
req.body: {}
req.params: {"id":"6354560eb0e10b544e5f0c8d"}
req.query: {}
{
  username: 'fcc_test_16664714387',
  count: 0,
  _id: '6354560eb0e10b544e5f0c8d',
  log: []
}

Notice the missing date in req.body for POST exercise and the subsequent empty log.

1 Like

Yeah, I noticed now. I forgot to add the condition for when the date is not provided. It passed all the test now. Thank you so much !