PLEASE HELP Back End Development and APIs Projects - Exercise Tracker

Tell us what’s happening:
I cant seem to pass the date tests. I am using toDateString() on my final response.json() to display all dates in “Day Mon DD YYYY” format as a string.

also test for “to” “from” and “limit” are failing even tho I get them to work in my browser

Please advise

Your project link(s)

solution: boilerplate-project-exercisetracker - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: Back End Development and APIs Projects - Exercise Tracker

Link to the challenge:

You have to handle dates that are not provided correctly. This modification of your code should be helpful.

  if( == ''){
    console.log('I think the date is an empty string.');
    // = new Date( = new Date(,10)
  } else {
    // = new Date(date).toDateString()
    console.log(`I think date is ${}, but it's not always defined.`);

Hi Jeremy,
Thanks for the response. I tried your code and you were right about using to get the date from the user if not empty however my tests are still not passing.

The date property from the log array returned by the GET …/logs is a string in “Day Mon DD YYY” format which I get by using the .toDateString() function on line 112

Also, test for ?to &from &limit is failing however those query parameters work when I use them in firefox ???

Log the response from POST exercise. The date is still invalid when not set in You can see that as well where you log from GET log right now.

I did a console.log(responseObject) in the POST /exercise route - I see that a date string is printed in the correct format just as in my GET /logs route

also when the date field is left blank - today’s date is printed
when garbage text is entered in date field - ‘Invalid Date’ is printed

Run the tests and have that route log the inputs and responses and you’ll see:

request.body: {"description":"test","duration":"60"}
request.params: {"_id":"63ae2da32f71eb1d507017e1"}
request.query: {}
I think date is undefined, but it's not always defined.
Post exercese:
  _id: new ObjectId("63ae2da32f71eb1d507017e1"),
  username: 'fcc_test_16723593314',
  description: 'test',
  duration: 60,
  date: 'Invalid Date'

I just ran this on a fresh fork of your repl.

I did the debugging methods you suggested and was able to find the mistakes I was making. Thank you very much for helping me earn this Certificate.

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