0

I am building an Ionic app, and trying to set custom headers for every GET request I do on the app.

This is the CustomHeaderController

angular.module('myHeader',[])
.controller('headerCtrl',['customHeader',function(customHeader){
var config = {headers:  {
'Authorization': 'Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==',
'Accept': 'text/html;odata=verbose',
"X-Request-from" : "{{vm.data.os}}" }};
$http.get('http://localhost:8100, config); }])

At the moment when I inspect the page, I do not get any custom header, just the default one.

Any clues? Appreciate it! Cheers.

1 Answer 1

1

You need to use interceptor in this case with every http request.

Interceptor Details

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

3 Comments

cheers mate! And if I want to check for only one request, for example lcoalhost:8100 ? Do I still have to use interceptors? Or I could use the code I have
Ideally in application there will be like as many as HTTP request, so its good habit to use intercepter.
Cheers! @Parvin Erande

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.