Reputation: 23
I'm trying to post the JSON object "updated" to nodeJS server....and save it to MongoDB using .update
.
Javascript in front-end:
$(".save-changes").click( function () {
var updated = $scope.users;
$http.post("/update", updated);
});
Node.js:
app.post('/update', function (req, res) {
MyUser.update( req.updated , function ( err, doc ) {
err ? res.send( err ) : res.redirect( '/' );
});
});
Upvotes: 0
Views: 41
Reputation: 4783
Try req.body.updated
in MyUser.update
.
app.post('/update', function (req, res) {
MyUser.update( req.body.updated , function ( err, doc ) {
err ? res.send( err ) : res.redirect( '/' );
});
});
Upvotes: 0