How to send header data in http request in Angular js

ajax, angularjs, html, javascript

Solution

   //store the header data in a variable 
    var headers = { 'Authorization': authToken };

    //Add headers with in your request
    $http.post('http://localhost/api/validate',user, { headers: headers } ).success(function() 

Problem

While trying to access a secured Api, I need to send header data with in my angular http requests javascript code : ``` $http.post('http://localhost/api/validate', user).success(function () { $scope.reset(); $scope.activePath = $location.path('/'); ``` How to send header data with in this request?

Original source