I am trying to make an update through a service. If I use postman with the same link as in the service, the update works fine.
Here is my code:
myservice.service.ts:
updateUser(userid){
let headers = new Headers();
headers.append('Content-Type','application/json');
console.log('http://localhost:3000/users/update/'+ userid);
return this.http.put('http://localhost:3000/users/update/'+ userid,
{headers: headers}).map(res => res.json());
}
inside routes/users.js
router.put('/update/:id', (req, res) => {
User.findByIdAndUpdate(req.params.id, {
$set: {
participates: true}
},
{
new: true
},
function(err, updatedUser){
if(err){
res.send("Error updating user");
} else{
res.json(updatedUser);
}
}
);
});
I do not get an error, but it does not seem to enter the router.put. What am i missing?