APIs and Microservices Projects : Exercise Tracker

Tell us what’s happening:
Please Help.

It passing all the tests except one where we have to add data to the exercise at /api/exercise/add.

This is what showing when to submit my solution-
// running tests 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 the current date. App will return the user object with the exercise fields added. // tests completed

Your code so far
Link to the code - https://glitch.com/edit/#!/join/daac4111-4772-452a-8afe-0c60109673e8

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

It means:

  • if any user exists in your database, you will just add the exercise details in an array of exercise under that user/username,
  • if user not found in the database you will add all the data including username by one click on the submit/add,
  • if user exist && if it has listed exercise in the database then you’ll just add/push the newly submitted exercise to exercise array in the database, other data will remain unchanged
  • you won’t make many users by same name
  • when you add the data you must include all data as mentioned here
  • since, date is optional, if the user gives no date- your code will record the current date (here you need condition)
  • finally you will return the last update data from the database, not all

If you follow the steps with a fresh mind, I hope you will get the point and solve the issues. But do not update username or _id for any case.

I checked your code, which has no connection with any database but you should, because this is not only to pass the test but it is the matter of your learning.

Hope this will help you.