Back End Development and APIs Projects - Exercise Tracker Just Need One Test To Pass

Tell us what’s happening:
Hi, recently i fix my code and just need to pass the test. Its fail at exercises route last test with message The response returned from POST /api/users/:_id/exercises will be the user object with the exercise fields added.

boilerplate-project-exercisetracker (1) - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 12; M2003J15SC) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Mobile Safari/537.36

Challenge: Back End Development and APIs Projects - Exercise Tracker

Link to the challenge:"/api/users/:_id/exercises", (req, res, next) => {
  let userId = req.params._id
  let description = req.body.description
  let duration = parseInt(req.body.duration)
  let date =

  if (!date) {
    date = new Date().toDateString()
  } else {
    date = new Date(date).toDateString();

  const expObj = {

  const updateUser = User.findByIdAndUpdate(
    { $push: { log: expObj } },
    { new: true },
    (err, updatedUser) => {
      if (err) {
        return console.log('update error:', err);
      } else {
        return console.log('update successfull', updatedUser);

  let returnObj = {
    "username": updateUser.username,
    "description": expObj.description,
    "duration": expObj.duration,
    "_id": userId,

My code which i think its wrong. Please help me, i dont have any idea where its going wrong

The /api/users/:_id/exercises is returning:

{"description":"test","duration":60,"date":"Mon Jan 01 1990","_id":"63d571ac072ea1ade1086a55"}

This is the example return:

  username: "fcc_test",
  description: "test",
  duration: 60,
  date: "Mon Jan 01 1990",
  _id: "5fb5853f734231456ccb3b05"

Something is missing?

Seems the id conflicted? Username ?

Oh, thank you. Its completed now. I just need to delete else statement and put returnObj there. Thank you for help

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