I believe I'm just doing something wrong here, but for some reason, my http.get() request always throws an error.
Here's an excerpt of my code:
import {Http, Response, Headers} from '@angular/http';
import 'rxjs/Rx';
...
export class CustomClass{
...
getAPI(){
this.http.get('http://ip-api.com/json')
.map((res: Response) => {
res.json();
})
.subscribe(
(data) => console.log(data),
(error) => console.error(error),
() => console.log(this)
);
}
}
I'm under the impression that this code block should simple get the response form http://ip-api.com/json and then output it. However, the only result I ever get is the error response and I can't figure out why.