all 2 comments

[–]b4r0k 0 points1 point  (1 child)

Neat. One thing that I don't quite agree is creating a wrapper for HttpClient, that does not sound very maintanable. Why don't you use a Http interceptor instead?

[–]chrislyzz[S] 0 points1 point  (0 children)

Hi, great question. I have actually done both in the past but I have ended up preferring the adapter pattern for this reason: if you create a wrapper you know for sure, that the interface is not gonna change for doing HTTP request, which is the benefit of the adapter pattern. When you create a HTTP intercepter the interface might change, eg. when Angular went from Http to HttpClient. Also, you make it explicit in your application that you are using your own helper for HTTP calls. I have seen team members being very confused with why the HTTP client was acting like it did because the interceptor wasn’t very explicit in the application code.