Tell us what’s happening:
Describe your issue in detail here.
My code works perfectly well on replit, but once submitted on FCC, it crashes saying “Cannot read property username of null”, I don’t know where the null is coming from.
Please when I log console.log(req.body) this is what I got
And that was why I used req.body[‘:_id’] to grab the user Id.
Yes I noticed the date is an empty string
Did you try logging it out when submitting? I mean when submitting the project to the test page.
It’s the reason why updatedPerson is null because it doesn’t find the id. When you use the form the id is on the body but when the tests POST to the endpoint it isn’t. You can use req.params or req.url to get the id.
When I fix the id and date it passes the two POST to exercises tests.
Edit: When doing these projects I suggest having the network tab open in the browser and looking at the data when submitting. You can see the payload and responses.
I also think reading the tests is helpful. Ideally, you shouldn’t have to look at the tests but I find it helpful.