Help: APIs and Microservices Projects - Exercise Tracker

Looking for some help from the community.

I’m stuck on /api/exercise/add/ and /api/exercise/log/. When I submit my Glitch URL, the last 3 cases fail. It appears to me that everything is returning as expected, so I’m hoping someone with a fresh mind can take a look and point me to the issue.

When I POST an exercise to /api/exercise/add/, the app returns:

{
"userId":"5ed677771d2b2a1238e894e0",
"description":"swim",
"duration":"20",
"date":"Sat May 25 2019",
"username":"test1234"
}

When I POST an exercise without a date to /api/exercise/add/, the app returns:

{
    "userId":"5ed677771d2b2a1238e894e0",
    "description":"swim",
    "duration":"20",
    "date":"Tue Jun 02 2020",
    "username":"test1234"
}

When I GET the exercise log from /api/exercise/log?userId=5ed677771d2b2a1238e894e0, the app returns:

{
    "userId":"5ed677771d2b2a1238e894e0",
    "username":"test1234",
    "count":3,
    "log":[
    {
        "description":"swim",
        "duration":20,
        "date":"Sat May 25 2019"
    }, 
    {
        "description":"swim",
        "duration":20,
        "date":"Tue Jun 02 2020"
    }, 
    {
        "description":"walk",
        "duration":90,
        "date":"Tue Jun 02 2020"
    }]
}

When I GET the exercise log with a date range from /api/exercise/log?userId=5ed677771d2b2a1238e894e0&from=2019-5-24&to=2019-5-26, the app returns:

{
    "userId":"5ed677771d2b2a1238e894e0",
    "username":"test1234",
    "count":3,
    "log":[
    {
        "description":"swim",
        "duration":20,
        "date":"Sat May 25 2019"
    }]
}

When I GET the exercise log with a limit from /api/exercise/log? userId=5ed677771d2b2a1238e894e0&limit=20, the app returns:

{
    "userId":"5ed677771d2b2a1238e894e0",
    "username":"test1234",
    "count":3,
    "log":[
    {
        "description":"swim",
        "duration":20,
        "date":"Sat May 25 2019"
    },
    {
        "description":"swim",
        "duration":20,
        "date":"Tue Jun 02 2020"
    }]
}

Glitch App linked below. Thanks in advance for looking!

Glitch: https://caramel-jumpy-timimus.glitch.me/

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

Challenge: Exercise Tracker

Link to the challenge:

Hello there,

This is what the tests are expecting as a response format:

const expected = {
          username,
          description: 'test',
          duration: 60,
          _id,
          date: 'Mon Jan 01 1990'
        };

You are not returning a parameter _id.

Hope this helps

Thanks @Sky020. This helped with one issue and led me to looking a little closer at some other things that ultimately allowed me to conquer this project!

In addition to my confusion stemming from the example project returning userId instead of _id, I also discovered I wasn’t returning duration as an int. Addressing that allowed me to complete that checkpoint.

Furthermore, I found I was returning count as the total number of log entries, not just the count of those returned. I also misinterpreted the limit property - I thought it meant the limit in minutes, i.e. 'show me all logs with duration <= limit'. When I looked closer at the example project, I realized it was limiting the number of results returned. Addressing that allowed the final 2 cases to resolve.

Thanks again!

No problem. We are looking to improve the backend projects, and your explanation of what misled you helps.