javascript - Angular interceptor gives blank output with no error -


i want inject content-type in $http. request. have following interceptor don't errors/output, i'm doing wrong?

  .factory('interceptor', ['$injector', '$q', function ($injector, $q) {         return function () {             return {                 request: function (config) {                     var deferred = $q.defer();                     config.headers['content-type'] = 'application/x-www-form-urlencoded';                      deferred.resolve(config);                     return deferred.promise;                 }             };         };      }])      .config(['$httpprovider', function ($httpprovider) {         $httpprovider.responseinterceptors.push('interceptor');     }]); 

.factory('interceptor', ['$injector', '$q', function ($injector, $q) {     return {         request: function (config) {             config.headers = config.headers || {};             config.headers['content-type'] = 'application/x-www-form-urlencoded';             return config;         },         response: function(response) {             return response || $q.when(response);         }     }; }]) 

i wish had more time test out, give try. it's variation of code used before add 'bearer' token headers.


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -