Answer the question
In order to leave comments, you need to log in
Why does mongoose send a 404 response on its own?
In general, there is a method that updates the user and sends an object with updated data:
exports.update = function(req, res){
if(req.diffUser){
User.update({_id:req.user.id},req.diffUser,function(err){
if(err){
throw err;
} else {
User.findById(req.user.id,'-password -salt -email',function(err,user){
if(err){
throw err;
}
if(!user){
res.status(400).json({type:'Error',message:'User not found =/...hmm'});
} else {
res.json(user);
}
});
}
});
} else{
req.status(400).json({type:'Error',message:'No difference'});
}
};
Answer the question
In order to leave comments, you need to log in
This is not done by the third line, but by the code that remains behind the screen. Most likely, the request routing is incorrectly built and the router does not understand that this method has taken over the return of the result. The router did not find the desired path and returned a 404.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question