Open Adamtpacz opened 1 year ago
function create(req, res) { Dog.findById(req.params.id) .then(function (dog) { Application.create({ name: req.body.name, phone: req.body.phone, emailAddress: req.body.emailAddress, numberOfPets: req.body.numberOfPets, address: req.body.address, message: req.body.message, dog: dog._id, user: req.user._id, userName: req.user.name, userAvatar: req.user.avatar }).then(function () { res.redirect(`/dogs/${req.params.id}`) }) .catch(function (err) { console.log(err) res.redirect(`/dogs/${req.params.id}`) }) }).catch(function (err) { console.log(err) res.redirect(`/dogs/${req.params.id}`) }) }
Code - Application Creation Controller Function
Comments