Hello everyone, mastering the MEAN stack and backend at the same time. Faced the problem of updating data in the database. The server responds 404 (Not Found). I think the problem is in the structure of the PUT request on the client, I have not done such requests before.

AngularJS

constructor($http, $scope, socket) { this.$http = $http; this.socket = socket; $scope.$on('$destroy', function() { socket.unsyncUpdates('product'); }); } this.$http.put('/api/products/', product) .then(function(res){ console.log('ok'); }) .catch(function(res){ console.log('error'); }) 

Express

 export function upsert(req, res) { if(req.body._id) { Reflect.deleteProperty(req.body, '_id'); } return Product.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec() .then(respondWithResult(res)) .catch(handleError(res));} 

Router

 router.put('/:id', controller.upsert); 

On the server side, I think everything is OK, product is an object in which there is a property that changes.

    0