I need help, on the FCC back end

I have this error ‘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 already put the dateString but i dont know it always gives me an error.

Your project link(s)
githubLink: GitHub - jondereck/jondereck-portfolio-app

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36

Challenge: Exercise Tracker

Link to the challenge:

ohh im sorry, here.

User.findByIdAndUpdate(

req.params._id,

{ $push: { log: newExercise } },

{ new: true },

(err, userUpdate) => {

  if (err) {

    console.error(err);

    res.send(err);

  } else {

    if (!userUpdate) {

      res.json({

        error: "_id does not exist",

      });

    } else {

      let newExerciseApiObj = {

        username: userUpdate.username,

        description: newExercise.description,

        duration: newExercise.duration,

        _id: userUpdate._id,

        date: new Date(newExercise.date).toDateString(),

      };

      res.json(newExerciseApiObj);

     

    }

  }

}

);

});

app.get("/api/users/:_id/logs", (req, res) => {

let userId = req.params._id;
User.findById(userId, (err, searchResult) => {

if (err) {

  res.json({

    error: "_id does not exist",

  });

} else {

  // *getting query string parameters if they are given

  if (req.query.from) {

    from = new Date(req.query.from).getTime();

  }

  if (req.query.to) {

    to = new Date(req.query.to).getTime();

  }

  /*

   * Filter of Array will be done using the EPOCH date

   */

  if (req.query.from !== undefined && req.query.to !== undefined) {

    searchResult.log = searchResult.log.filter((filteredLogs) => {

      let exerciseDate = new Date(filteredLogs.date).getTime();

      return exerciseDate >= from && exerciseDate <= to;

    });

  }

  if (req.query.from !== undefined) {

    searchResult.log = searchResult.log.filter((filteredLogs) => {

      let exerciseDate = new Date(filteredLogs.date).getTime();

      return exerciseDate >= from;

    });

  }

  if (req.query.to !== undefined) {

    searchResult.log = searchResult.log.filter((filteredLogs) => {

      let exerciseDate = new Date(filteredLogs.date).getTime();

      return exerciseDate <= to;

    });

  }

no, i didnt log,

can you give me example? please

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.