title: Why is my http.put Request not working? MEAN-Stack
body: <p>I'm building an app with a API and so far all the http request (get, post) are working fine. Now i added a put Request to my Service and for some reason it's not working. </p>
  
  <p>Here is where i call the Service Function: </p>
  
  <pre><code>export class ChatStartComponent implements OnInit {
  
    @ViewChild('d1') d1:ElementRef;
  
    socket = io.connect('http://localhost:3000');
  
    constructor(private usersService: UsersService) {
      this.currentUser = JSON.parse(localStorage.getItem('currentUser'));
      this.currentUserName = this.currentUser.name;
      this.usersService.updateUser(this.currentUser._id); &lt;--update Users does not
      /*this.usersService.getUsers()  &lt;-- getUsers does work
        .subscribe(users =&gt; {
          this.users.push(users);
        });*/
    }
  </code></pre>
  
  <p>The Parameter, currentUser._id does exist and i can console log it at that point.</p>
  
  <p>Here is the Service Function:</p>
  
  <pre><code>  addUser(newUser) {
      var headers = new Headers();
      headers.append('Content-Type', 'application/json');
      return this.http.post('http://localhost:3000/api/user', JSON.stringify(newUser), {headers: headers});
    }
  
    updateUser(_id: string) {
      var set = {
        loggedIn: true
      };
      console.log(set, _id);
      return this.http.put('http://localhost:3000/api/update/' + _id, JSON.stringify(set))
        .map(res =&gt; res.json());
    }
  </code></pre>
  
  <p>The http.post call above is working fine but the updateUser put is not working at all. The console.log is getting triggered and i do get the id logged just fine, but the http.put call doesn't work. </p>
  
  <p>Here is the Server-side code:</p>
  
  <pre><code>router.put('/update/:id', function(req, res) {
    console.log('hello there');
    let user = req.body;
    userService.update(req.params._id, req.body)
      .then(function() {
        res.sendStatus(200);
      })
      .catch(function(err) {
        res.sendStatus(err).send(err);
      });
  });
  </code></pre>
  
  <p>The console.log doesn't get triggered here, which tells me that the call never reaches the API. </p>
  
  <p>Here is the Server-side Service function that gets called in it (or doesn't get called right now):</p>
  
  <pre><code>function update(_id, set) {
    var deferred = Q.defer();
  
    db.users.findById(_id, function(err, usr) {
      if(err) deferred.reject(err.name + ': ' + err.message);
  
      if(usr) {
        updateLoggedIn();
      } else {
        console.log('something's wrong here');
      }
    });
  
    function updateLoggedIn() {
      db.users.update({ _id: _id}, { $set: set }, function(err, doc) {
        if(err) deferred.reject(err.name + ': ' + err.message);
  
        deferred.resolve;
      });
      return deferred.promise;
    }
  }
  </code></pre>
  
  <p>I don't get any error, but like i said the console.log on the server-side isn't getting triggered, which makes me belive that i did something wrong with the client-side call. I just can't figure out what. Any help is appreciated!</p>