Trying to study angular. To write a product review on the service, you need to pass token in the http request header. How can I do that? Here is the code:

 $scope.savingcomment = function (answer, answerForm){ console.log($scope.answer.comment); $http.post("http://smktesting.herokuapp.com/api/reviews/2",{"rate":5,"text":"fffddf"}).success(function (answ) { console.log($scope.answer.comment); }) .error(function (err) { console.log('Что-то пошло не так'); }) }; 
  • what kind of token? what's the title? - Grundy

1 answer 1

For example, you can do so. Taken from the office. the documentation is the same. Accordingly, any heder can be passed to the headers, including and your token as you need.

  var req = { method: 'POST', url: 'http://example.com', headers: { 'Content-Type': undefined }, data: { test: 'test' } } $http(req).then(function(){...}, function(){...});