Exercise Tracker back-end project

Test cases are broken. Some of test cases are giving an undefined value to the DATE field of ADD EXERCISE. The undefined value causes an “Invalid Date” output to all DATE OUTPUTS. Making impossible to pass in the penultimate test

Your project link(s)

solution: boilerplate-project-exercisetracker - Replit

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

If the tests were broken the demo project wouldn’t pass.

If I look in the network tab when submitting I see an Invalid Date for the last GET to /logs

Request URL: https://boilerplate-project-exercisetracker.vitormagno.repl.co/api/users/a23d2e5d9447d319b6c8c4cc59485cdb/logs

Response: {"_id":"a23d2e5d9447d319b6c8c4cc59485cdb","username":"fcc_test_16504838445","count":1,"log":[{"description":"test","duration":60,"date":"Invalid Date"}]}

When I look at the response from the limit=1 test I see two objects.

Request URL: https://boilerplate-project-exercisetracker.vitormagno.repl.co/api/users/c6e1c38283ff0a15c569647ee2ed0d6f/logs?limit=1

Response: {"_id":"c6e1c38283ff0a15c569647ee2ed0d6f","username":"fcc_test_16504838460","count":2,"log":[{"description":"test","duration":60,"date":"Mon Jan 01 1990"},{"description":"test","duration":60,"date":"Wed Jan 03 1990"}]}

Edit: Just to be clear. The date is optional.

You can POST to /api/users/:_id/exercises with form data description , duration , and optionally date . If no date is supplied, the current date will be used.

If one isn’t submitted you have to create it. So when req.body.date is undefined you can’t just pass undefined into the Date constructor.

1 Like

thank you, I haven’t seen it before. All make sense now.