2
저는 여기서 뭔가 잘못하고 있다고 생각하지만, 어떤 이유로 http.get() 요청이 항상 오류를 throw합니다. 이 코드 블록은 간단한 응답 형태 http://ip-api.com/json
를 받아야한다는 인상을 해요Angular2 Http GET은 항상 오류를 throw합니다.
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)
);
}
}
다음 출력이 :
은 여기 내 코드의 발췌입니다. 그러나 내가 얻은 유일한 결과는 오류 응답이며 이유를 파악할 수 없습니다.