Question about Exercise Tracker - retrieving a full exercise log at api/exercise/log

So I’m trying to figure out how “/api/exercise/log” is supposed to work in:

"
4. I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). Return will be the user object with added array log and count (total exercise count).
"

I added to a new user to the database, and the id for this is “rkfmRTSpm”

When I do:

https://fuschia-custard.glitch.me/api/exercise/log?{rkfmRTSpm}”

OR

https://fuschia-custard.glitch.me/api/exercise/log?rkfmRTSpm

I get “unknown userId”

but when I do

https://fuschia-custard.glitch.me/api/exercise/users

and search for “rkfmRTSpm”, it finds the associated user.

I am clearly missing something. Can someone please point out what it is?

Much appreciated.

You are missing the key for your query in the URL, try something like this:

https://fuschia-custard.glitch.me/api/exercise/log?_id=rkfmRTSpm

or

https://fuschia-custard.glitch.me/api/exercise/log?id=rkfmRTSpm

and then use req.query._id or req.query.id (depending on your choice) when querying the database.

1 Like

I still get “unknown userId”

https://fuschia-custard.glitch.me/api/exercise/
is the example project given in the project description:
https://learn.freecodecamp.org/apis-and-microservices/apis-and-microservices-projects/exercise-tracker

Try https://fuschia-custard.glitch.me/api/exercise/log?userId=H10qUgwT7. It works for me.

Alright thanks! - that seems to work

1 Like

Yes that is the solution. They should have made this more obvious though, a normal user would not be able to translate “/api/exercise/log?{userId}[&from][&to][&limit]” to what he actually needs to put in.

1 Like