AngularJS $http custom header for all requests -
i wondering if there way configure $http requests header adding custom info. config :
var config = {headers: { 'authorization': 'basic d2vudhdvcnrobwfuoknoyw5nzv9tzq==', 'accept': 'application/json;odata=verbose' } };
but $http calls make in different services. i'm sure there solution :d.thanks
you can create $http
interceptor extend header:
myapp.factory('httprequestinterceptor', function () { return { request: function (config) { config.headers['authorization'] = 'basic d2vudhdvcnrobwfuoknoyw5nzv9tzq=='; config.headers['accept'] = 'application/json;odata=verbose'; return config; } }; }); myapp.config(function ($httpprovider) { $httpprovider.interceptors.push('httprequestinterceptor'); });
Comments
Post a Comment