2017-11-17 3 views
0

안녕하세요, 'flightAware'API 데이터에 액세스하려고합니다. 나는 우편 배달부에 요청을했고 그것은 비행에 대한 모든 데이터를 완벽하게 반환합니다.API 데이터 각도 5

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. 

코드 :

constructor(private _http: HttpClient) { } 

    getSites(): Observable<ISearchResponse> { 
    return this._http.get<ISearchResponse>(this._siteURL) 
     .do(data => console.log('All: ' + JSON.stringify(data))) 
     .catch(this.handleError); 
    } 
    private handleError(err: HttpErrorResponse) { 
    console.log('SearchEngineService: ' + err.message); 
    return Observable.throw(err.message); 
    } 
} 

ISearchResponse

interface ISearchResponse { 

    airports: IItem[]; 

} 

IItem

interface IItem { 
    name:string; 
} 
가 내 각 응용 프로그램에서 시도

나는 오류

우편 배달 결과 :

"airports": [ 
      { 
       "fs": "JFK", 
       "iata": "JFK", 
       "icao": "KJFK", 
       "faa": "JFK", 
       "name": "John F. Kennedy International Airport", 
       "street1": "JFK Airport", 
       "city": "New York", 
       "cityCode": "NYC", 
       "stateCode": "NY", 
       "postalCode": "11430", 
       "countryCode": "US", 
       "countryName": "United States", 
       "regionName": "North America", 
       "timeZoneRegionName": "America/New_York", 
       "weatherZone": "NYZ178", 
       "localTime": "2017-11-17T09:37:34.462", 
       "utcOffsetHours": -5, 
       "latitude": 40.642335, 
       "longitude": -73.78817, 
       "elevationFeet": 13, 
       "classification": 1, 
       "active": true, 
       "delayIndexUrl": "https://api.flightstats.com/flex/delayindex/rest/v1/json/airports/JFK?codeType=fs", 
       "weatherUrl": "https://api.flightstats.com/flex/weather/rest/v1/json/all/JFK?codeType=fs" 
      } 
+0

더 나 자신을 생각했다 @RahulSingh 나 –

+0

에 CORS 문제처럼 보인다 활성화합니다. 해결책을 제안 할 수 있습니까? – JohnDoe

+0

데이터를 보내는 서버에 Corss 원점 지원 기능을 추가해야합니다. 해당 지역의 개발자라면이 API를 개발자에게 요청해야 할 수도 있습니다. –

답변