Tell us what’s happening:
Describe your issue in detail here.
Someone guide me where i have missed a hint because my second last test isn’t passing what could be the problem and how can i go about it?
Thanks in advance.
You should construct the date correctly when creating an exercise that way you do not have to do anything to the res objects for the date. Save the date to the DB in the correct format.
Just as an aside, new Date(req.body.date).toDateString() in the log route is returning Invalid Date.
i have tried my level best with one date parameter and it’s fine now but am stuck with the other date parameter,please am humbly waiting for your guidance as i will be very grateful if you did so.
As I said, if you just save the dates in the correct format to begin with you do not have to do anything.
Example code.
const date = dateFromParam ? new Date(dateFromParam).toDateString() : new Date().toDateString()
Otherwise, you will have to loop the log array you get back and transform the date property by passing each of the log date strings you have now to a date constructor.
Partial pseudo-ish code.
{ ...props, date: new Date(theWrongDateString).toDateString() }
I don’t see where you have done anything I suggest you do in your code.
But I do think I have to make a correction with my map example because if you just spread all the props, I think you will get a bunch of properties you do not want on the log objects. So you have to return a specific object with just the three properties that are the requirement for the log objects.
So inside your res.json for the log property, map data and inside the map callback return a new object with the description, duration, and date. The date needs to be formatted using toDateString. When I do that your code passes.