Submitted July 21, 2018 at 03:33AM by randygbiv
Friday, 20 July 2018
[Help] Having issues understanding why my code isn't deleting the data from mongo.
Good evening everyone,I'm working with the MEAN stack. I'm using mongoose. The node/express code goes as follows:app.delete('/api/posts/:id', function(req, res){Post.findByIdAndRemove(req.params.id, function(err, deletedPost){if(err){console.log(err);} else{res.json(deletedPost)}})The angular code is as follows:$scope.deletePost = function(id){$http.delete('/api/posts/' + id).success(function(data){$scope.posts = data;console.log(data);}).error(function(data){console.log('Error: ' + data);})};The html looks like:
Submitted July 21, 2018 at 03:33AM by randygbiv
Submitted July 21, 2018 at 03:33AM by randygbiv
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment