Exercise Tracker Microservice - I need help

Tell us what’s happening:
I am working on freeCodeCamp Exercise Tracker Microservice in Replit.
I put in my MONGO_URI code in the Replit Secret Environment Variable file.
I install the latest versions of mongoose and mongodb on Replit.
I was able to pass 7 tests. I need help with the 9 failed tests.

  1. Each element in the array returned from GET /api/users is an object literal containing a user’s username and _id .
  2. The response returned from POST /api/users/:_id/exercises will be the user object with the exercise fields added.
  3. A request to a user’s log GET /api/users/:_id/logs returns a user object with a count property representing the number of exercises that belong to that user.
  4. A GET request to /api/users/:id/logs will return the user object with a log array of all the exercises added.
  5. Each item in the log array that is returned from GET /api/users/:id/logs is an object that should have a description , duration , and date properties.
  6. The description property of any object in the log array that is returned from GET /api/users/:id/logs should be a string.
  7. The duration property of any object in the log array that is returned from GET /api/users/:id/logs should be a number.
  8. 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.
  9. You can add from , to and limit parameters to a GET /api/users/:_id/logs request to retrieve part of the log of any user. from and to are dates in yyyy-mm-dd format. limit is an integer of how many logs to send back.

Your project link(s)
Please take a look at the Replit code. I appreciate any help.

  • What codes am I missing?
  • Are there any syntax errors in Replit?
  • Please show me how I can fix this.

thank you

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

Logging input<>output and comparing to example helped me to solve this exercise. My mistake was a typo in using “logs” instead of “log” key :slight_smile: Always like this – expect some conspiracy behind a bug, but it is a simple typo in the end.
Here what I used

app.use(({ method, url, query, params, body }, res, next) => {
  console.log('>>> ', method, url);
  console.log(' QUERY:', query);
  console.log(' PRAMS:', params);
  console.log('  BODY:', body);
  const _json = res.json;
  res.json = function (data) {
    console.log(' RESLT:', JSON.stringify(data, null, 2));
    return _json.call(this, data);
  console.log(' ----------------------------');

After logging you could try to repeat input on example service and compare with your output.

audreychin56 To return literal out of a model, you might want to use .toObject() method of mongoose model and make sure you cast input numbers into numbers, because they are being sent as strings with numbers(“25” → 25).