I have a GET route where all user's are returned.How can i remove specific fields from the response like password? // create a new user account & create token router.post('/user', function(req, res) { if (!req.body.username || !req.body.password || !req.body.email) { res.json({success: false, msg: 'Please enter a userame, password and an email.'}); } else { var newUser = new User({ username: req.body.username, password: req.body.password, email: req.body.email }); // save the user newUser.save(function(err) { if (err) { res.json({success: false, msg: 'Username/email already exists.'}); }else{ res.json({success: true, msg: 'Successful created new user.',user: newUser }); } }); } });
Submitted January 06, 2017 at 01:17AM by farhansyed7911
No comments:
Post a Comment