Back End Development and APIs Projects - Exercise Tracker

I am failing on this task which says 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. Here is my solution
app.get(‘/api/users/:_id/logs’, (req, res) => {
const { from, to, limit } = req.query

UserInfo.findById(req.params.id, (, user) => {

if (user) {
  if (from || to || limit) {
    let logs = user.log;
    
    let filteredLogs = logs
      .map(log => {
        const formattedLogDate = new Date(log.date)
        const date_string = formattedLogDate.toDateString();
      
        log.date = date_string;
        return log;
      })
    const slicedLogs = limit ? filteredLogs.slice(0, limit) : filteredLogs
    user.log = slicedLogs
  }
  console.log(user.log);
  res.json(user)
}

Your project link(s)

solution: boilerplate-project-exercisetracker (1) - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.70

Challenge: Back End Development and APIs Projects - Exercise Tracker

Link to the challenge:

  • it seems wrong cause its missing an underscore, as it’s defined in “route”

see adjusting this solves it or not, happy learning :slight_smile:

the underscore is there

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