13

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?

3
  • Did you find a solution for this? I found this but it did not work abandon.ie/notebook/simple-loading-spinner-for-backbonejs Commented Jun 3, 2015 at 22:01
  • 1
    Write a wrapper to parse. And there you can have interceptor Commented Jun 5, 2015 at 16:49
  • I am already using this wrapper I forgot to say I am using this Parse wrapper. github.com/rafbgarcia/angular-parse-wrapper which is using promises BTW but I can't intercept it in a clean way Commented Jun 6, 2015 at 22:40

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for your answer, I forgot to say I am using this Parse wrapper. github.com/rafbgarcia/angular-parse-wrapper which is using promises BTW
@MuhammadHassan can't we switch all those call using $http?
Well that's a good idea. but we will loose all the ease of Parse JS SDK parse.com/docs/js/guide and will have to use the very verbose and less object oriented REST SDK parse.com/docs/rest/guide#queries Do you have any other ideas? Can I intercept angular $q promises?
Can we use an idea like this stackoverflow.com/questions/16797209/… I am not very expert with angular/$q so I can't customize it. All I need is to intercept when $q promise is created and when its resolved/rejected
@MuhammadHassan surely we could implement by the way the answer has implemented.. but are you using $q while making call to parse.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.