-
Notifications
You must be signed in to change notification settings - Fork 110
Description
In this commit: 67871ac ngx-restangular was changed from using HttpClient
's request
method to the handle
method of HttpBackend
which bypasses the ability to use Angular's HTTP interceptors.
I looked around in issues, but didn't see a reason why this was done.
Unfortunately, for us, ngx-restangular's own interceptors aren't good enough for our use case, as they don't intercept every request (i.e. anything made with allUrl
or oneUrl
) and you can't abort the request (i.e. in the event that you want to return a cached response). Plus, extra config is necessary in order to take advantage of other Angular modules that do provide Angular interceptors (like the loading bar plugin that's mentioned in #144).
I forked the repo and just replaced a couple instances of HttpBackend
and changed the handle
method to request
and plugged the built files into an app that we're migrating to ngx-restangular from restangular, and all seems to function the same, except now we can use native Angular interceptors (ngx-restangular interceptors still work though), and can just plug in the loading bar mentioned above without having to add custom code since all requests that ngx-restangular makes are going through HttpClient
now.
Here's the fork: https://github.com/jaydiablo/ngx-restangular
And the specific commit where I've changed back to HttpClient
: jaydiablo@9c09c3e
This has the ability to fix #144, #95, #182 and perhaps others.
That said, I'm not sure why this support was removed (when both Angular interceptors and ngx-restangular interceptors appear to work fine) so just wanted to get some clarification on that before proposing the change from my fork as a PR.
Also, is there any sort of test suite? I've tested in our app, but that probably doesn't touch all of ngx-restangular's surface area. I see there's some karma config, but no specs. Is the "demo" app the best way to test changes?
Thanks!