I have complete all the requirement to get passed the exercise tracker project. even though I’m still not getting passed following task. I have no idea why?
The date property of any object in the log array that is returned from GET /api/users/:id/logs should be a string… Use the dateString format of the Date API
I had a similar problem yesterday. Passing all tests except this one. I did use toDateString() and couldn’t find the problem. Made some random “improvements / (fixed a typo)” and suddenly it passed. Not sure this is importent: Submitting an existing username creates a new user (with the same username) (as in the demo); in the database the dates also have the dateString format.
in the exercise tracker I m not getting passed following 2 tasks.
The response returned from POST /api/users/:_id/exercises will be the user object with the exercise fields added
The date property of any object in the log array that is returned from GET /api/users/:id/logs should be a string… Use the dateString format of the Date API.
but all two tasks I have completely done. you can check it below links. why is that? can someone help me on this?
it helped me passed first one. still fails following one. As you said i changed it to todatestring(). I changed the way of handling the empty dates too
The date property of any object in the log array that is returned from GET /api/users/:id/logs should be a string… Use the dateString format of the Date API
Please do not create duplicate topics. I have merged your threads.
You can post in your own thread to bump it up, just don’t do it too often and be patient.
Open the dev tool in the browser and when submitting look at the response object you are sending back for the exercises and logs endpoints. Look at the date.
Log out req.body.date and make sure your logic for handling empty dates is sound. Before you were checking for an empty string, now you are checking for null. Are you sure that will work?
You say it works but unless I’m missing something it really shouldn’t for the missing date requirment.
Log out req.body.date and tell me what type you see when no date is provided?
Log out the new document after you have created one. What happens when you create a document where one of the property values is using the type you logged above?
Log out inside the null check if statement, are you sure you are entering it when you expect to?
Just in case I’m being too vague
req.body.date should be undefined when no date is provided. Passing an undefined value to the document constructor for one of the properties should result in that property missing from the document. Accessing a missing property should return undefined. At no point should the property exist with a null value (as far as I can tell).
I think something wrong from my end. undefined works. it doesnt seems work for me. so i didnt try submitting it. I guess somthing wrong with my browser. sorry for the bother. thank you so much!
It is not your browser, you are just not handling the missing date correctly. Maybe I just didn’t explain it well enough.
You can not set one of the document properties to undefined, if you do that it will not get created and will be missing in the document. Check req.body.datebefore you create the document and handle the missing date. Then add the date you create manually to the document.