Hello everybody,
I’m in a desperation mode, still don’t understand why I do not pass the validation of https://www.freecodecamp.org/learn/apis-and-microservices/apis-and-microservices-projects/exercise-tracker
My project: https://positive-fantastic-fight.glitch.me/
I’m still not passing this validation: “I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). App will return the user object with added array log and count (total exercise count).”
Strangely, I pass the last one. My Json output is exactly as is the sample project’s. Please help if you can, thanks!
User with exercises id: 5ed12d30250eaf14348e3c5f
Welcome, dhadhazi.
Potentially, esspecially if you are passing the last test, you need to clear your DB, then run the tests again. As you could be failing this portion of the tests:
const logRes = await fetch(url + `/api/exercise/log?userId=${_id}`);
if (logRes.ok) {
const { log } = await logRes.json();
assert.isArray(log);
assert.equal(1, log.length);
} else {
throw new Error(`${logRes.status} ${logRes.statusText}`);
}
Perhaps, your person is already in your db, and is returning an array of length greater than 1.
Hope this helps
1 Like
Sadly it’t not working:( Cleared all my DB. I see the test makes 4 users, and 3 exercises (2 for 1 user and 1 for another one), but thanks for the idea!!! After checking everything multiple times for both the site they provide and mine, I realised that when the bot submits the date it won’t come in the req body as empty, but undefined. I did not handle that well, so it somehow returned a different log, but i passed somehow the adding test. Now it is working!
1 Like
Can you share the server code?
I believe the test is broken. I passed this test earlier and even got the certification. But now I tried using the same glitch project url (https://hussey-fcc-microservices.glitch.me/), the same 4th test is not passing even though it satisfies the requirement and work as intended.
(Spoiler - contains full solution: https://glitch.com/edit/#!/hussey-fcc-microservices)
Yes. I think the test is broken (or rather the setup for this test). I submitted a PR to fix this. https://github.com/freeCodeCamp/freeCodeCamp/pull/39266