0

I'm not able to add a custom HTTP header in the GET queries in my angularJS application. I'm trying to add a custom header like toto : testing value

into a http get call in AngularJS.

I tried the following:

            $http.get('http://www.google.com',{headers : {'toto' : 'test value'}});

I also tried a solution using $http.default.header.common but it leads to the same result and the result is:

Access-Control-Request-Headers: toto

It modifies the value of the Access-Control-Request-Headers ? What do I misunderstand here? Any idea of how I can achieve that?

2
  • Call your URL service instead of 'www.google.com' and try use the example of API Reference (docs.angularjs.org/api/ng/service/$http): var req = { method: "GET", url: "http://example.com", headers: { "Content-Type": "plain/text" } } $http(req).then(function(){...}, function(){...}); Commented Oct 2, 2015 at 12:59
  • I just created a JSFiddle with your code and it works as expected. So you are missing something else. Commented Oct 2, 2015 at 18:19

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.