Exercise Tracker - count property in user object is not recognized

Tell us what’s happening:

The count property in the user object returned by GET /api/users/:_id/logs is not recognized.

Naturally, the testers failed tests 10 through 15. But only the last test 16 passed.

If there is a defect in the user object returned by my API, I think that test 16 should also fail, but the more I think about it, the more confused I am.

Someone please teach me.

Your project link(s)

solution: boilerplate-project-exercisetracker - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/108.0.1462.54

Challenge: Back End Development and APIs Projects - Exercise Tracker

Link to the challenge:

Log your route inputs and every response from every route while debugging. Do that and your POST exercise route says:

POST exercise
req.body: {"description":"test","duration":"60"}
req.params: {"_id":"63a0538b7f2e77f028c0e42a"}
req.query: {}
I think there is a validation error
{"errors":[{"msg":"date is invalid","param":"date","location":"body"}]}

You are not handling empty dates correctly.

The more I keep seeing particular test fail for something that is not related to the main point of the test (the count property), I think the following test should be modified so that it tests specifying a date AND not specifying a date.

You can POST to /api/users/:_id/exercises with form data description, duration, and optionally date. If no date is supplied, the current date will be used.

Currently, the test is only testing when the request has date, so users think they have met the requirement. It is not until the later test for the count property, since that test does not specify a date for the exercise to be added.

Apparently I had to consider the case where request.body.date itself doesn’t exist.

Even if it is not entered on the screen, I misunderstood that request.body.date itself exists inside the request and empty data is set in the data.

When I added a request.body.date existence check to the processing of post api/users/:_id/exercises, all tests passed.

Thanks to your guidance, I was able to pass the test. Thank you very much.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.