0

I'm setting a header like this in Angular in the app.run()

$http.defaults.headers.common['Test'] = 'Foobar';

But I can't find the "Test" request parameter on the server. What's wrong?

1
  • Why you are not setting headers like: $http({ 'url':...... , 'method': ..... , 'header': .......}) Commented Feb 25, 2016 at 17:23

2 Answers 2

2

use $httpProvider instead. like this

$httpProvider.defaults.headers.common['test'] = 'Foobar'

Don't forget to inject it into your function

Sign up to request clarification or add additional context in comments.

1 Comment

And be sure to do it in a config block instead of a run block.
0

I do believe you want to put it within the app.config()

Comments

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.