Reputation: 3
I am logging the error "res.status is not a function" when using this route.
Any idea how to solve this?
Best regards!
exerciseRouter.post('/update/:id', (res, req) => {
Exercise.findById(req.id)
.then(exercise => {
exercise.username = req.body.username;
exercise.description = req.body.description;
exercise.duration = Number(req.body.duration);
exercise.date = _Date_.parse(req.body.date); exercise.save()
.then(() => res.json('Exercise updated!'))
.catch(err => res.status(400).json('Error: ' + err));
})
.catch(err => res.status(400).json('Error: ' + err));
});
Upvotes: 0
Views: 409
Reputation: 1651
You are confused in places 'req' and 'res', they should be the other way around:
exerciseRouter.post('/update/:id', (req, res) => {
Upvotes: 2