Exercise tracker issue

Tell us what’s happening:
I am working on the Microservice and API course project section,
I tried to submit the solution but the section is giving error on two-point, I have check that part on my own i didnt find any issue pls check it

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0.

Challenge: undefined

Link to the challenge:


I took a quick look at your code. It seems to me you are returning the JSON object without saving the user to your database first.

    req.body.date = new Date();
  let log = {description:req.body.description, duration:req.body.duration,date:req.body.date};
  // delete log.userId;
  // return res.send(req.body);
   User.findByIdAndUpdate({_id:req.body.userId},  { $push: { log:log} },(err,result)=>{
      return res.send(err)
          date: req.body.date
          res.send("error occured");

the problem is with this part, I think so.
because I got the wrong answer for this route only.
and this the data is saved in the database.

Ok, I think I see where the problem is. Your variables do not have the correct type. For example req.body.duration is a string but the value corresponding to the key “duration” in your database and the JSON object returned in the browser needs to be an integer. Same thing with date (needs to be a string in the browser and a Date object in your database if I remember correctly).

1 Like