Exercise tracker not passing all tests working properly on glitch

Tell us what’s happening:
Code is working perfectly but passing only four tests:
I can provide my own project, not the example url.

I can create a user by posting form data username to /api/exercise/new-user and returned will be an object with username and _id .

I can get an array of all users by getting api/exercise/users with the same info as when creating a user.
I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). App will return the user object with added array log and count (total exercise count).

cant get it to pass:

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. App will return the user object with the exercise fields added.

I can retrieve part of the log of any user by also passing along optional parameters of from & to or limit. (Date format yyyy-mm-dd, limit = int)

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/80.0.3987.149 Safari/537.36.

Challenge:

Link to the challenge:

Why can’t you give us links to the code and demo? It makes it much harder to help you if you can’t give us that.

sorry could not post links on my first post on freecodecamp

Ahh, ya, forgot about the posting restrictions. I haven’t done this project so I might not be able to fully help you, but I’ll ask some questions.

I am able to add a user. When I do it shows me the JSON object of the user created. When I try to add an exerise, I get the following:

Cannot read property 'username' of undefined

Is this supposed to work from the interface on the web page or should I be doing something else to test it?

My code has Passed all the tests except the 2nd one. Though I don’t see any problem, it works exactly what is in the test. Here is the test…

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. App will return the user object with the exercise fields added.

But my /api/exercise/add works properly. it returns an object which contains the newly added exercise data like this…
{"username":"Nalaa","description":"dgds","duration":"56","_id":"iTSku_Y6Q","date":"Sat Apr 04 2020"}

SO PLEASE HELP ME TO PASS THIS TEST. Thanks in advance…
Here is the link-

Raihan’s Exercise Tracker

Oh I have solved it! The problem in my code was…

  • My Code was returning the duration key as a string, I used parseInt() to make it an int number.
  • I hadn’t set the condition if date returns undefined

My advise to the people who are having problems in this project, YOU SHOULD MAKE A GREAT USE OF console.log(), you can also check what fcc is testing through console.log().
Thanks

done and dusted. thanks to all for the help

Im also having the same issue, Its passing all tests except the last one.

here is my glitch link, any help would be appreciated

Thank you!
duration: parseInt(duration) saved me!