javascript – 如何在Angular js中的http请求中发送头数据

在尝试访问安全的Api时,我需要在我的角度http请求中发送标头数据

javascript代码

$http.post('http://localhost/api/validate',user).success(function () {
        $scope.reset();
        $scope.activePath = $location.path('/');

如何在此请求中发送标头数据?

最佳答案
   //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() 

相关文章

vue阻止冒泡事件 阻止点击事件的执行 <div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些