AngularJS passing data to $http.get request

前端 未结 7 690
无人及你
无人及你 2020-11-22 13:01

I have a function which does a http POST request. The code is specified below. This works fine.

 $http({
   url: user.update_path, 
   method: \"POST\",
   d         


        
相关标签:
7条回答
  • 2020-11-22 13:29

    Starting from AngularJS v1.4.8, you can use get(url, config) as follows:

    var data = {
     user_id:user.id
    };
    
    var config = {
     params: data,
     headers : {'Accept' : 'application/json'}
    };
    
    $http.get(user.details_path, config).then(function(response) {
       // process response here..
     }, function(response) {
    });
    
    0 讨论(0)
提交回复
热议问题