How to use http in Angular 2 via angular-cli?

I initially tested and wrote a tutorial for Pluralsight by using the angular-cli version 1.0.0-beta.9.

However, I’ve tried today with the latest version and for the life of me I couldn’t figure out how to use HTTP to call some service.

In the end, I figured what the issue was, so I’m putting it out here so it may be useful to someone else as well.

So, when I installed angular-cli with npm install -g angular-cli I haven’t at first noticed this error:
UNMET PEER DEPENDENCY [email protected]

What I ended up doing now was

npm install webpack -g && npm install webpack --save-dev

and now I can normally include Http into my component like this:

import { Http, Response } from '@angular/http';

and then use it within a class like this:

Hope this helps someone.

Written by Nikola Brežnjak