Whenever i fire this put method :
return $http.put('/posts/' + post._id + '/upvote', {
headers: {Authorization: 'Bearer '+auth.getToken()}
}).success(function(data){
post.upvotes += 1;
});
I get the following error :
PUT http://localhost:3000/posts/56d89bfbb906ee1305fea2cf/upvote 401 (Unauthorized)
From what I understand, this is an angular issue with the way that its put method supports sending data to the server.
Can anyone who has dealt with this issue before help me out by.
-Thank you very much in advance
Try setting the HTTP header before hand:
$http.defaults.headers.common.Authorization = 'Bearer '+ auth.getToken();
Then call your PUT request