I'm a bit confused on how to do a http get call. My app.service is like so:
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
@Injectable()
export class AppService {
constructor(private http: Http){}
fetchData(){
return this.http.get('http://date.jsontest.com/').map(
(res) = > res.json()
).subscribe(
(data) => console.log(data)
);
}
}
This leads to an error of Cannot find name 'res'.
My app.module has the HttpModule.
Having looked through the Angular 2 doc on HTTP requests, they have something like getHeroes (): Observable<Hero[]>. But I am not sure exactly what is contained under the import { Hero } from './hero'; line.