Adding an interceptor for Restangular

4,202 views
Skip to first unread message

Mason Jones

unread,
May 22, 2013, 1:12:26 PM5/22/13
to ang...@googlegroups.com
I came across a very nice approach to adding a spinner for http requests, which does it by adding an interceptor to the httpProvider service. There's a good example documented in this blog post:


However, I'm using Restangular instead of httpProvider, and I'm wondering if there's a similar way to do this for Restangular and perhaps generically for other services/providers? Or does this work only because httpProvider has the built-in responseInterceptors notion?

Thanks for any ideas!


-- Mason

mlegenhausen

unread,
May 23, 2013, 4:47:47 AM5/23/13
to ang...@googlegroups.com
Looking in the restangular code shows it uses ng-resource which uses $http, so the interceptor approuch should work too.

Gonto

unread,
May 23, 2013, 6:08:37 PM5/23/13
to ang...@googlegroups.com
Hey,

You have 2 options here.

1) Use $http interceptor as he suggested. You can do that using defaultHttpFields

2) You can use requestInterceptor and responseInterceptor implemented in Restangular


Bests,
Gonto

Mason Jones

unread,
May 24, 2013, 5:30:18 PM5/24/13
to ang...@googlegroups.com
Great, thanks for the reply. I'll look into those both!
Reply all
Reply to author
Forward
0 new messages