Exercise tracker add problem

Why its not passing “add exercise” test case but working properly on glicth…I have tried many ways but still not passing.Please look for it

CODE for /api/exercise/add

exports.add = function(req, res, next) {
  let user_id = req.body.userId,
      description = req.body.description,
      duration = req.body.duration,
      date = req.body.date ? new Date(req.body.date) : new Date()
  
  if(req.body.userId) {
    User.findOne({_id: user_id}, function(err, data) {
      if(err) next(err);
        if(!data || data._id !== user_id) {
          next({status: 400, message: 'unknown _id'});
        } else {
          User.findByIdAndUpdate(user_id,
                      {$push: {log: {description, duration, date}} },
                      {upsert: true, new: true},
                      (err, data)=> {
            if(err) next(err);
            if(!data) { next({status: 400, message: 'unknown _id'}) }
            else { res.json({
              username: data.username,
              _id: data._id,
              description,
              duration, 
              date : date.toDateString()
            }) }
          });
        }
    });
  } else { next({status: 400, message: 'unknown _id' })}
  
  if(!description) {next({status: 400, message: 'missing description'})}
  if(!duration) {next({status: 400, message: 'missing duration'})}
  
}

code :

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums