Exercise Tracker Project Help || Link: https://mirror-starfish.glitch.me/

Tell us what’s happening:
My Project is working but It is not accepted by freeCodeCamp. It is showing some unwanted errors.

Your code so far

Your browser information:

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

Challenge: undefined

Link to the challenge:

Hey @sainiharit2001, what about giving us more detail on where these unwanted errors are appearing? In your glitch console or on the FCC project submission page? Have you accomplish and tested all the exercise’s requirements?

Tip: Try to be more specific when you open a new post here, so we can be more effective in our help. :wink:

Cheers mate!

I went to your page, submitted a new user, then I copied its ID and tried to insert an new exercise to it, but leaving the date field blank. Your server returned and error when it should NOT.

       "message":"Cast to Number failed for value \"NaN\" at path \"date\"",
         "message":"Cast to number failed for value \"NaN\" at path \"date\"",
"_message":"Exercise validation failed",
"message":"Exercise validation failed: date: Cast to Number failed for value \"NaN\" at path \"date\"",

The exercise says:

  1. I can add an exercise to any user by posting form data userId(_id), description, duration, and optionally date to /api/exercise/add. If no date supplied it will use current date. Returned will be the user object with also with the exercise fields added.

I think you should review your field validations because it must be allowed to insert a new exercise without passing a date. That means making the date field something like this in your schema:

date: { type: Date, required: false }