Sunday 25 June 2017

Any idea why this PATCH method wont work?

router.patch('/user/:id', function(req, res, next){ User.update({_id: req.params.id}, {$set: req.body}).then(function(){ User.findOne({_id: req.params.id}).then(function(user){ // console.log(req.body.assets[0].location.coordinates); // console.log(user); res.send(user); }); }); }); So above is my patch method which I would like to update part of an array however it is just clearing the array and replacing it with the one value passed.Example of the patch request: localhost:4000/api/user/592c851cb7beb31a9c2bfd74Body: { "assets" : [{"name": "number1", "location":{"type": "point", "coordinates": [-83.500, 24.10]}}] }Thanks, Ed.

Submitted June 25, 2017 at 04:32PM by thelynched

No comments:

Post a Comment