ufwxwa
Last Updated: July 12, 2017
·
4.902K
· otupman

AngularJS and $http - transform the request *and* the response

Occasionally you might wish to pre-process requests or responses that go out/come into Angular before the standard Angular processing gets to them.

For example, perhaps you decide to use Binary JSON rather than pure JSON (no, no clue why). To achieve this you can modify $httpProvider.defaults.transformResponse and $httpProvider.defaults.transformRequest. They're arrays, so you can add in a series of transformers, if you wish.

myModule.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.transformResponse = function(data) {
      return performSomeTransformation(data);
    };
  }])

Your transformed data will then be passed on to your $http handler in nice object form (assuming that's what you wanted). You could, if you were strange, just pass back the received data without converting to JSON.

1 Response
Add your response

29086

We can get the password for the instagram account and in this way you can know how to hack instagram accounts online to get the account details you want to know.

over 1 year ago ·