Exercise Tracker Functioning but Failing Tests

Tell us what’s happening:
I think my exercise tracker is functioning properly, when I test it myself I can see it is returning the requested information (up through the optional date field tests, I haven’t checked that thoroughly yet because I cannot get earlier test to pass).

Can anyone give me a hint here? Is it the way I am naming fields? Is it the format of the returned date?

I am reallllyyyy hitting the wall on this one, I need some help! Anything is much appreciated. I see some other posts about this, but none are addressing the problems I am experiencing (or if they are there isn’t any further guidance).

Your code so far
Here is my repl.it and you can find all the routing in the server.js document.


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36.

Challenge: Exercise Tracker

Link to the challenge:

I had to play with both projects (and double check that mine still passes the tests) and here is what I saw.

story 1 and 2: same output
story 3:

{"username":"bob","id":"5f910628bd9608003612886c","exercise":{"date":"Thu Oct 22 2020 04:13:35 GMT+0000 (Coordinated Universal Time)","description":"jogging","duration":20}}


{"username":"roberta","_id":"5f910663f5e44200615fb03f","description":"jogging","duration":20,"date":"Thu Oct 22 2020"}

story 4:
yours: could not reach


story 5: same as 4

In story 3, the return has a different structure and the _id name is different. I think I remember the test being very picky about the time format.

In story 4/5, I can’t reach the endpoint. I could reach my /api/exercise/log endpoint with a url like /api/exercise/log?userId=5f910663f5e44200615fb03f and my route looks like

app.get('/api/exercise/log', (req, res) => {...);

and I get the fields out of req.query.userId for example. It looks like your endpoint is using route parameters, which is useful for a finite list but not for variables that can have essentially any value.

Also, you are throwing an unhandled promise rejection warning from somewhere, so some of the async code (mongoose) is unhappy about something.

So to sum up, it’s probably the date format and the _id versus id on the early tests, and you need req.query.* on the log routes.

Whoa @jeremy.a.gray thank you SO much for taking the time to sift through that mess!

I see now about queries :). I was being a confused coding student and thinking I had to specify what the queries would be in the api endpoint WOOF. Ok, that makes a lot more sense now and I got that bad boy to pass the tests!

And thanks again for pasting the format of your passing tests because that was extremely helpful! No more stabbing around in the dark.

Very, very happy to be done with this project and to move along to the next one. I’m sure I will find new ways to make the Mongoose unhappy :). Thanks again, I really appreciate you taking the time!!