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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -