Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why was use of HttpClient explicitly removed? #185

Open
jaydiablo opened this issue Jan 16, 2020 · 2 comments
Open

Why was use of HttpClient explicitly removed? #185

jaydiablo opened this issue Jan 16, 2020 · 2 comments

Comments

@jaydiablo
Copy link

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!

@pvillaverde
Copy link

Hey there,

I'm in the middle of a migration from AngularJS and was wondering why the interceptors didn't work as before. As stated by @jaydiablo, there are many cases where the restangular's own interceptors dont fit.

I would like to know if there's any reason whatsoever or any update on this. Could it be a setting for the user if it's really needed? I think i'm going to use @jaydiablo 's fork for now, but since it's not on npm repo it also has its caveats.

@xuyi0130
Copy link

xuyi0130 commented Oct 2, 2020

Hi Folks, any comment on this one?

It's really important to let people have interceptors to work.

Bunch of compatibility issues come out with disability of interceptors, and it discourages people for applying this module into their angular apps. Even for users have been using this dependency since the Angularjs era, i.e., myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants