Unclear instructions for "Exercise Tracker"

I have completed the project but one user story keeps giving incorrect:
“The response returned from POST /api/users/:_id/exercises will be the user object with the exercise fields added.”

The sample API site returns:
{"_id":“629a03a88413530938cc4526”,“username”:“1”,“date”:“Fri Jun 03 2022”,“duration”:1,“description”:“desc”}

My API returns:
{"_id":“629a09f4e5706c139927f068”,“username”:“1”,“date”:“Fri Jun 03 2022”,“duration”:“1”,“description”:“desc”}

I don’t understand what’s wrong here and I don’t know what “the user object” is supposed to be. I’d appreciate any help.

My Replit code

After some digging in the “network” tab in Chrome’s developer tools I found out the problem.
Both responses looked identical since they are displayed as a stringified JSON object. The “duration” key should have an int-type value, but in the JSON object I was returning it was the same value parsed from the request body, which was a string.

The fix:
res.json({..., duration: dur, ...}) => res.json({..., duration: parseInt(dur), ...})

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