Back End Development and APIs Projects - Exercise Tracker

Tell us what’s happening:

Hi everyone,

I’m almost done with the Exercise Tracker from the course. It can surely be done better but I’m passing all tests except the one before the last. It says the following: 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.

However, I am actually using dateString and it seems that I’m returning a string. I used typeof to check for it.

I really don’t understand where the bug is. Can anyone help me spot it ?

Thanks a lot !

Your code so far

My project can be found here: boilerplate-project-exercisetracker - Replit

Your browser information:

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

Challenge Information:

Back End Development and APIs Projects - Exercise Tracker

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.

Not sure why this isn’t failing because you are not handling the optional date.

POST without a date payload

https://boilerplate-project-exercisetracker.yan28.repl.co/api/users/65380540596fae666e57cae2/exercises
Response: {
    "_id": "65380540596fae666e57cae2",
    "username": "fcc_test_16981701745",
    "date": "Invalid Date",
    "duration": 60,
    "description": "test"
}

Making all the logs routes return "date": "Invalid Date"

Request URL: https://boilerplate-project-exercisetracker.yan28.repl.co/api/users/65380540596fae666e57cae2/logs
Response: {
    "username": "fcc_test_16981701745",
    "count": 1,
    "_id": "65380540596fae666e57cae2",
    "log": [
        {
            "description": "test",
            "duration": 60,
            "date": "Invalid Date"
        }
    ]
}
2 Likes

Thanks for mentionning this, I had not realized it indeed. Gonna implement it ASAP. This might also be why I’m having the issue mentionned in my original post.

That was it ! Now that I’m handling the optional date, I’m passing all tests. Thanks so much for the hint !

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