Tell us what’s happening:
Tests 1, 2, 3, 5 and 6 pass. Test 4 does not pass for some reason even though the payload is what was shown in the Hint
Your code so far
The problematic code is here:
app.post('/api/exercise/add', function(req, res, next) {
const { userId, description, duration, date } = req.body
User.findById(userId, (err, user) => {
if(err) next(err)
user.log.push({
_id: user._id,
description,
duration,
date: date ? date : new Date().toDateString()
})
user.save((err, data) => {
const { _id ,username } = data
if(err) next(err)
res.json({
username,
description,
_id,
duration: Number(duration),
date: date ? date : new Date().toDateString()
})
})
})
})
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15
.
Challenge: Exercise Tracker
Link to the challenge:
Link to repl:
https://repl.it/@AdrianMarcelMar/boilerplate-project-exercisetracker#server.js