Tell us what’s happening:
Describe your issue in detail here.
In the tests I am passing all of them up until this one:
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.
However When I add an exercise without a date it seems to properly use today’s date.
And I’m getting this CastError in my console only with the testing, but not when I add an exercise myself, it looks like there is no _id passed in for the exercise. I’m not sure how to proceed
User {
username: 'fcc_test_16745410654',
_id: new ObjectId("63cf7809e05ebf6eb2d22e22")
} saved.
Form Body: [Object: null prototype] {
description: 'test',
duration: '60',
date: '1990-01-01'
}
undefined
CastError: Cast to ObjectId failed for value "{ _id: undefined }" (type Object) at path "_id" for model "User"
Your project link(s)
solution: boilerplate-project-exercisetracker - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Challenge: Back End Development and APIs Projects - Exercise Tracker
Link to the challenge: