Back End Development and APIs Projects - Exercise Tracker

Tell us what’s happening:
Greetings CodeCampers! Can please anyone identify what I’m doing wrong in this project since it behaves identicaly to the example app but when I submit the project it results in the following:

"
// running tests
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.

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

Test 12 : 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.

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

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

Test 15 : 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.
// tests completed
"

I’m stuck in this for some time therefore any help is apreciated! Thank you in advance!

Your project link(s)
Solution Link

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: Back End Development and APIs Projects - Exercise Tracker

Link to the challenge:

Should I store the date in my exercise db scheme (exSchema) as String type instead of Date type or is it irrelevant?

You are mishandling dates that are not in req.body. Modifying part of your POST exercise route:

      if (date == 'Invalid Date') {
        console.log(`I think date ${req.body.date} is invalid.`);
        return res.json({ error: 'date is invalid' });
      }

yields on the affected tests:

I think date undefined is invalid.

However, the spec clear details what is supposed to be done with an undefined date.

Note that undefined, null, and the empty string are all different in JavaScript.

1 Like

Hey @jeremy.a.gray ! You re awsome! tomorrow I’ll give it a try and then I’ll share feedback (:

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