I rewrote my Exercise Tracker, which was able to pass all the tests, so that the server logic and database logic were in separate files, but, even though the code is largely the same, it’s now unable to pass Tests 10 through 15, all of which involve GET /api/users/:_id/logs
. (Interestingly, it can pass Test 16.)
What’s also bizarre is that, while my original version never appeared to get requests for exercise logs for users that didn’t have any exercises added yet, the newest one does—a lot, in fact. I updated my code so that it will return a user object where count = 0
and log = []
for those cases, but it still can’t pass all the tests.
Here’s an example of some output from my new version:
User created:
{ username: 'fcc_test_16512089598', _id: '626b72ffe4fe116f680d28d0' }
Exercise log requested:
{}
{
_id: '626b72ffe4fe116f680d28d0',
username: 'fcc_test_16512089598',
count: 0,
log: []
}
(Note: The empty object underneath the Exercise log requested
text represents the contents of req.query
.)
As you can see, the test requested the exercise log for a user immediately after creating it. And it actually did it again to the same user later in the test even though it still hadn’t added anything to that user. Nothing at all like this happens when using my original program. I’ll put links to them below, so please feel free to try running them. You will see just how different the input they get from the test routine is.
I would like to know if anyone else has experienced something like this. I’m just so confused about why the updated version can’t pass all the tests even though the code is mostly the same (save for the fact that it’s separated into two files now). If it’s possible to have someone look at it, I can post links to each version on my GitHub. Thank you in advance.