Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom interceptor angularjs application using Parse service

I am trying to implement an interceptor for my server responses (PARSE) with angularjs, I have seen this project that uses the $httpProvider to register the interceptor.

since my service is not using $http service (is using PARSE), is there any way of implement my interceptor in the same clean way that the project sample?

like image 530
Javier Hertfelder Avatar asked May 29 '13 12:05

Javier Hertfelder


1 Answers

Instead of using Parse service, I'd think of call parse.com API by using $http service only just we need to pass certain headers like X-Parse-Application-Id & X-Parse-REST-API-Key so that you could write your own interceptor that would have an control & watch over the request/response.

Code

$http({method : 'GET',
   url: 'https://api.parse.com/XXXXXXX', 
   headers: { 'X-Parse-Application-Id':'YYYYYYYYYYYY', 
   'X-Parse-REST-API-Key': 'ZZZZZZZZZZZZ'}
})
.success(function(data){})
.error(function(err){});

Inspired from this answer

like image 71
Pankaj Parkar Avatar answered Sep 28 '22 05:09

Pankaj Parkar