I'm having a study project using Node JS with MongoDB and I'm having a hard time saving a record in the database, I'm using the method that way.
function postRestaurant (req, res) {
var restaurants = new Restaurants(req.body);
restaurants
.save
((err, restStored) => {
if(err){
res.status(500).send({message: 'Error do servidor'});
}else{
if(!restStored){
res.status(404).send({message: 'No existe restaurant'});
}else{
res.status(200).send({restaurants: restStored});
}
}
});
}
When I submit the method it is falling into error 500, where am I wrong?