-2

Why is this header code not working? If I do not put the header, only the JSON, the table works. But if I am going to set it on the site header to get the JSON, it doesn't work. Is this a working query? Do I have a missing delimiter?

    var myTable=angular.module('myTable',[]);
myTable.controller('tableCtrl',function($scope,$http){
$http("http://staging.api.sample.com/activity.json", {header: {Authorization: 'NkgjkdleLKSldksLKSd'}}) .success(function(response) {
    debugger
    $scope.members=response.events;
     $scope.totals = response.paging;
});

});

1 Answer 1

1

$http accepts config object only

There are sortcut function such as get, which take first parameter as url and second as config.

You invocation should look like

$http.get("http://staging.api.sample.com/activity.json", {headers: {Authorization: 'NkgjkdleLKSldksLKSd'}})

Also make note it is headers not header.

2
  • yeah i tried d other shortcut function for 'get' like $http({url: 'staging.api.sample.com/activity.json', method: 'get'}) nothing happens. i dunno why isn't working ,
    – Flizz
    Jul 30, 2015 at 5:22
  • finally it works , yea ,, you're right . it's headers not header , i add 's' and it works , haha , tnx men!
    – Flizz
    Jul 30, 2015 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.