Angular Http deprecated??!!

I know that this post is a little click batey, but I was in a total shock when I heard the news and you won’t believe what happened next.

Angular developers are outraged, I think

You may be asking when did this happen ( 20 Aug 2017 apparently) and what am i supposed to do now, I’ve got this tutorial that I’m following but this geyser is using Http!

Don’t stress, Angular is now using an improved method to handle HTTP requests using HttpClient. I’m going to go over some basics.

Firstly you will need to add HttpClient to your app.model.ts file in the imports section. You may be asking do I have to, my reply is if you want this to work yes.

Cool, so with that done we have access to all the HttpClientModule’s tricks.
I have created a service component to show off my http skills, be sure to import the httpClient as …HttpClient on top of your typeScript file like so.

So you’ve happily imported your HttpClient, and created your constructor with (http: HttpClient). Now you’re seeing a compile error and thinking…

what is dees?!

If you add a “private” in the constructor you will see that the http will be available throughout that specific ts file and the compile error will magically disappear , so do not stress.

You may not have tried using a service components, this is just to clean up your code and put it into good reading order. Best practice for api calls to be located into these service component files. As you can see in the screenshot below that i reference the service call to get access to the api calls for my application.

i.e. be sure to not share end points to the public, but this end point is for practice and funzies so knock yourself out with jsonplaceholder.typicode.com

For more information about httpClient be sure to checkout Angular docs.