Tell us what’s happening:
Test wont pass: Says I can add an exercise to any user by posting form data userId(_id), description, duration, and optionally date to /api/exercise/add. If no date supplied it will use current date. App will return the user object with the exercise fields added.
Your code so far
app.post('/api/exercise/add', (req, res) => {
const { userId, description, duration, date } = req.body;
const dateObj = date === '' ? new Date() : new Date(date);
const newExercise = {
_id: userId,
description,
duration: +duration,
date: dateObj.toDateString()
}
exercises.push(newExercise);
return res.json(newExercise);
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Exercise Tracker
Link to the challenge:
https://eggplant-lizard-boot.glitch.me